salut j'ai crée un bouton mots de oublié et une classe versification ,l’utilisateur doit taper son carte identité pour afficher son mot de passe mais le probléme quand je clique sur mot de passé oublié je tombe sur un message de exception
voila ce que j'ai fait
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
59
60
61
62
public class Verification extends Activity {
 
 
	EditText verifi;
	Button verification2;
 
 
	public String ReadSettings(Context context){ 
        FileInputStream fIn = null; 
        InputStreamReader isr = null; 
 
        char[] inputBuffer = new char[255]; 
        String data = null; 
 
        try{ 
         fIn = context.openFileInput("fichier.txt");       
            isr = new InputStreamReader(fIn); 
            isr.read(inputBuffer); 
            data = new String(inputBuffer); 
 
            Toast.makeText(context, " "+data,Toast.LENGTH_SHORT).show(); 
            } 
            catch (Exception e) {       
                      Toast.makeText(context, "Settings not read",Toast.LENGTH_SHORT).show(); 
            } 
 
            return data; 
       }
 
 
	public void verification1 (View v)
{String name=verifi.getText().toString();
 
if(name.equals("0926882"))
{	Toast.makeText(this,"mot CIN correct" ,Toast.LENGTH_SHORT);
ReadSettings(getBaseContext());
startActivity(new Intent(this,Principal.class));
}
else
{
	Toast.makeText(this,"mot CIN incorrect" ,Toast.LENGTH_SHORT);
	}
startActivity(new Intent(this,Principal.class));
 
}
 
	public void onCreate(Bundle savedInstanceState)
	{
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.verification1);
 
 verifi=(EditText)findViewById(R.id.verifier);
 verification2=(Button)findViewById(R.id.verification);
 verification2.setOnClickListener(new OnClickListener() {
 
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		verification1(verification2);	
	}
});
	}}
et j'ai l'appel de classe vérification dans la bouton mot de oublié
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
	if(v==ok1) {
			startActivity(new Intent(this, Verification.class));
		}
voila logcat
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
06-10 09:50:57.123: ERROR/AndroidRuntime(280): FATAL EXCEPTION: main
06-10 09:50:57.123: ERROR/AndroidRuntime(280): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.application/com.example.application.Verification}: java.lang.ClassCastException: android.widget.Button
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.os.Looper.loop(Looper.java:123)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at java.lang.reflect.Method.invokeNative(Native Method)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at java.lang.reflect.Method.invoke(Method.java:521)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at dalvik.system.NativeStart.main(Native Method)
06-10 09:50:57.123: ERROR/AndroidRuntime(280): Caused by: java.lang.ClassCastException: android.widget.Button
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at com.example.application.Verification.onCreate(Verification.java:70)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
06-10 09:50:57.123: ERROR/AndroidRuntime(280):     ... 11 more