Bonsoir,

Dans mon appli, un nom s'affiche au hasard dans un textView.
Je dois écrire dans un EditText une réponse.

Dans mes resources, j'ai :

<string name="Coq">Poule</string>

Donc si l'aleatoire m'affiche : Coq
Je dois répondre : Poule

Comment vérifier si la réponse est bonne ou fausse.
Merci


MainActivity
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
 
public class MainActivity extends Activity {
 
	@Override	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);	
 
 
		final TextView textOne = (TextView) findViewById(R.id.textView1);	
		EditText textRep = (EditText) findViewById(R.id.editText1);
		Button aleatoire = (Button) findViewById(R.id.button1);	
		Button validation = (Button) findViewById(R.id.btn2);
 
		final String[] myNames = {"Coq", "Canard", "Lapin", "Chien", "Chat", "Cheval", "Ane", "Cerf", "Sanglier"};	
 
		Math.random();
 
		aleatoire.setOnClickListener(new View.OnClickListener() {			
 
			public void onClick(View v) {
 
				int rando = (int) (Math.random() * 9);				
		//			textOne.setText(myNames[rando]); //3eme hyptho 	
 
// Affichage du tirage aléatoire				
				textOne.setText((myNames[rando]) + ("\n")+  " La femelle de cet animal est ?"+ ("\n") +"Mettre la réponse sans l'article."+" exemple : grenouille" );
			}
		});
	}     
	}
	//	validation.setOnClickListener(new View.OnClickListener() {
 
//			@Override
//			public void onClick(View v) {
	//			
		//		if ("nom".equals(textOne.getText().toString()) &&"femin".equals(textRep.getText().toString())) {
 
		//			Toast.makeText(MainActivity.this, "BRAVOOooo", Toast.LENGTH_LONG).show();
		//		}else{
		//			Toast.makeText(MainActivity.this, "Erreur", Toast.LENGTH_LONG).show();
 
 
 
 
 
 
 
//Comparaison de la réponse.
//				TextView textView =  (TextView) findViewById(R.id.textView1);
//				EditText editText = (EditText) findViewById(R.id.editText1);
//				String nom =  (String()= name("nom"); 
	//			String reponse = String()=value("reponse");
 
//		Intent i = new Intent(MainActivity.this, Question.class);
//					i.putExtra("rando", myNames); //on en fait un extra. original
//			startActivity(i);

Strings resources
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<resources>
 
    	<string name="nom">femin</string>
 
 
    <string name="app_name">Random</string>
    <string name="hello_world">Hello world!</string>
    <string name="level_greeting">moyen</string>
   	<string name="action_settings">Settings</string>
    <string name="textview">TextView</string>
    <string name="btn1">aleatoire</string>
	<string name="hello">Bonjour le Monde</string>
 
	<string name="Coq">Poule</string>
   <string name="Canard">Cane</string>
   <string name="Lapin">Lapine</string>
   <string name="Chien">Chiennee</string>
   <string name="Chat">Chatte</string>
   <string name="Cheval">Jument</string>
   <string name="Ane">Anesse</string>
   <string name="Cerf">Biche</string>
   <string name="Bison">Bisonne</string>	
 
    <string name="question">Dwa Activitée.</string>   
 
</resources>