1 pièce(s) jointe(s)
Créer une liste selon un résultat de question
Bonjour,
Je termine mon application de quiz, mais encore un petit problème:
Dans le quizz, on pose une question.
On y répond.
La réponse est bonne, pas de soucis on passe à la question suivante.
La réponse est fausse, on passe à la question suivante.
A la fin de la série de question ( nombre de question choisi au début).
Il y a un récapitulatif avec :
Nombre de questions posées.
Nombre de Bonnes réponses.
Nombre de mauvaises réponses.
Un TextView devrait montrer la liste des réponses fausses avec :
- la question
- la réponse du joueur
- la réponse attendue.
Mais voilà c'est là que je bloque, je n'arrive à afficher que la dernière mauvaise réponse.
Et c'est la liste de toutes les réponses fausses que je veux (que je désire).
Le code "Activité Principale:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
| public class Quiz1Activity extends Activity {
String userReponse;
private EditText editText;
private int nbreQuestions = 4;
int index;
static int reponseb = 0;
static int reponsef = 0;
int score = (reponseb+reponsef);
int mascQ = 0;
int femiR = 0;
int repUserF = 0;
int numeQuestion;
String masc ;
String femi ;
String propos;
String repAttend;
String repUser;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz1);
editText = (EditText) findViewById(R.id.editText1);
Button aleatoire = (Button) findViewById(R.id.button1);
final String[][] myNames = {
{"Samedi", "Sobota"},
{"Canard", "Cane"},
{"Lapin", "Lapine"},
{"Jeudi", "Czwartek"},
{"Chat", "Chatte"},
{"Cheval", "Jument"},
{"Désolé", "Przepraszam"},
{"Mardi", "Wtorek"},};
aleatoire.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Resources res = getResources();
TextView verdict;
Random rand = new Random();
// for(int i = 0; i < nbreQuestions; i++);
index = rand.nextInt(myNames.length);
masc = myNames[index][0];
femi = myNames[index][1];
if ((reponseb+reponsef) < nbreQuestions) {
((EditText) findViewById(R.id.editText1)).setText("");
((TextView) findViewById(R.id.textView2)).setText("");
((TextView) findViewById(R.id.textView1)).setText(masc);
String chaine = res.getString(R.string.compteur,(reponseb+reponsef)+1,nbreQuestions);
TextView compteur = (TextView) findViewById(R.id.textView3);
compteur.setText(chaine);
Button validation = (Button) findViewById(R.id.btn2);
editText = (EditText) findViewById(R.id.editText1);
validation.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
userReponse = editText.getText().toString();
String verdict = getString (R.string.verdict) ;
String verdictBad = getString (R.string.verdictBad);
TextView myTextView = (TextView) findViewById(R.id.textView2);
myTextView.setText(verdict);;
myTextView.setTextColor(Color.GREEN);
if (userReponse.equals(femi)) {
myTextView.setText("Text en Vert");
myTextView.setTextColor(Color.GREEN);
((TextView) findViewById(R.id.textView2)).setText(verdict);
reponseb++;
}
else {
myTextView.setText("Text en Rouge");
myTextView.setTextColor(Color.RED);
((TextView) findViewById(R.id.textView2)).setText(verdictBad);
repAttend = femi;
repUser = userReponse;;
propos = masc;
reponsef++;
};;}});}
else
{
((EditText) findViewById(R.id.editText1)).setText("");
((TextView) findViewById(R.id.textView2)).setText("");
((TextView) findViewById(R.id.textView1)).setText("");
((TextView) findViewById(R.id.textView4)).setText(" Fin du questionnaire !");
Button recap =(Button) findViewById(R.id.btnRecap);
recap.setOnClickListener(new OnClickListener() {
public void onClick (View view) {
// TODO Auto-generated method stub
Intent intent = new Intent(Quiz1Activity.this, Recap.class);
Bundle pass1 = new Bundle();
pass1.putString("passInfo1", repUser.concat(""));
intent.putExtras(pass1);
Bundle pass2 = new Bundle();
pass2.putString("passInfo2", repAttend.concat(""));
intent.putExtras(pass2);
Bundle pass3 = new Bundle();
pass3.putString("passInfo3", propos.concat(""));
intent.putExtras(pass3);
startActivity(intent);
;;;;;;;;;;}{;}{;;;};;;{{{};;;;;;;;;;;;;;;;;;;;;;;;;{{{{}{{}}{}{}}}{};; ;; ;;
; ; ; ; ; ;; ; ; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
}}{} };});;;;;}};});}} |
Code de la "Seconde Activité"
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public class Recap extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recap);
final TextView reponse = (TextView) findViewById(R.id.VotreReponse2);
Bundle pass1 = this.getIntent().getExtras();
String reponseUser = pass1.getString("passInfo1");
reponse.setText(reponseUser);
final TextView reponse2 = (TextView) findViewById(R.id.Solution2);
Bundle pass2 = this.getIntent().getExtras();
String repAttend = pass2.getString("passInfo2");
reponse2.setText(repAttend);
final TextView reponse3 = (TextView) findViewById(R.id.proposition2);
Bundle pass3 = this.getIntent().getExtras();
String propos = pass3.getString("passInfo3");
reponse3.setText(propos);
}
} |
Pièce jointe 185549
Quelqu'un saurait-il me guider un peu ?
Merci d'avance pour votre aide.