Bonjour,

Je suis en train de péter un plomb devant un code qui marchait très bien il y 1 heure et qui plante dès que je démarre mon application.

Main.java :
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
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
/* Entreprise : Emergence IT
 * Développé par : Maxime Nicole
 * Application : Quiz
 * Version : 1.0
 * Date de création : 02/11/2011
 * Date de modification : 15/11/2011
 */
 
package fr.emergenceit.quiz;
 
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
 
public class Main extends Activity {
 
	Button btnConnect;
	Button btnInscrip;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
 
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
    	// On récupère tous les éléments de notre interface grâce aux ID
    	btnConnect = ((Button)this.findViewById(R.id.connection)); // Ligne  31
    	btnInscrip = ((Button)this.findViewById(R.id.inscription));
 
		// On attribut un écouteur d'évènement à tous les boutons
    	btnInscrip.setOnClickListener(new View.OnClickListener() {
 
			public void onClick(View v) {
				goToInscrip();
			}
 
		});
 
    	btnConnect.setOnClickListener(new View.OnClickListener() {
 
			public void onClick(View v) {
				goToMenuPrinc();
 
			}
		});
 
    }//Fin onCreate()
 
	protected void goToMenuPrinc() {
 
		//On récupère les deux champs, puis le texte saisi
		EditText login = (EditText)findViewById(R.id.pseudo);
		String loginStr = login.getText().toString();
		EditText pass = (EditText)findViewById(R.id.password);
		String passStr = pass.getText().toString();
 
		Intent intent = new Intent(Main.this, Login.class);
 
		//On rajoute les valeurs à l’Intent
		//en tant qu’extra a ce dernier.
		//Les extras sont différenciés par un “id” (string)
		intent.putExtra("login", loginStr);
		intent.putExtra("password", passStr);
 
		//Si un des deux champs est vide, alors on affiche les erreurs
		if (passStr.equals("") || loginStr.equals("")) {
			Toast.makeText(getBaseContext(),
			"Le Pseudo et le Mot de passe sont obligatoires",
			Toast.LENGTH_SHORT).show();
			return;
		}
 
		//Si on respecte les conditions plus haut
		//On accède à l'écran du menu principal
		this.startActivity(intent);
 
	}
 
	protected void goToInscrip() {
		Intent intent = new Intent(this, Inscription.class);				
		//On démarre l'activité
		this.startActivity(intent);
 
	}
 
	@Override
	protected void onDestroy() {
		//On arrête le service : "ServicePacks". (qui a été démarré dans MenuPrincipal.java
		//Intent bindIntent = new Intent(this, ServicePacks.class);
		//stopService(bindIntent);
		super.onDestroy();
	}
}
main.xml :
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
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
 
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/bg">
 
	<LinearLayout
	    android:id="@+id/linearLayout1"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content" 
	    android:layout_gravity="right" 
	    android:layout_marginTop="30px">
 
		<TextView
		    android:layout_width="wrap_content"
		    android:layout_height="wrap_content"
		    android:layout_weight="0.00"
		    android:paddingTop="10dp"
		    android:text="Pseudo : "
		    android:textColor="#FFFFFF" 
		    android:textSize="20dp" 
		    android:layout_marginRight="20px"/>
 
		<EditText
		    android:id="@+id/pseudo"
		    android:layout_width="200dp"
		    android:layout_height="wrap_content"
		    android:layout_marginRight="20px"
		    android:layout_weight="0.00" 
		    android:layout_gravity="right" android:saveEnabled="true" android:text="Xenonmax">
 
		    <requestFocus />
		</EditText>
 
	</LinearLayout>
 
	<LinearLayout
	    android:id="@+id/linearLayout2"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content" 
	    android:layout_gravity="right">
 
		<TextView
		    android:layout_width="wrap_content"
		    android:layout_height="wrap_content"
		    android:paddingTop="10dp"
		    android:text="Mot de passe : "
		    android:textColor="#FFFFFF" 
		    android:layout_marginRight="20px" 
		    android:textSize="20dp"/>
 
		<EditText
		    android:id="@+id/password"
		    android:layout_width="200dp"
		    android:layout_height="wrap_content"
		    android:layout_weight="1"
		    android:password="true" 
		    android:layout_marginRight="20px" 
		    android:saveEnabled="true" 
		    android:text="******"/>
 
	</LinearLayout>
 
	<CheckBox
	    android:id="@+id/checkBox1"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:text="@string/souvenir" 
	    android:layout_gravity="right" 
	    android:layout_marginRight="40px" 
	    android:textColor="#FFFFFF"/>
 
	<LinearLayout
	    android:id="@+id/linearLayout3"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
 		    android:layout_gravity="right">
 
 
		<Button
		    android:id="@+id/inscription"
		    android:layout_width="wrap_content"
		    android:layout_height="wrap_content"
		    android:layout_marginRight="100px"
		    android:layout_marginTop="10dp"
		    android:text="Créer un compte" />
 
 
		<Button
		    android:id="@+id/connection"
		    android:layout_width="wrap_content"
		    android:layout_height="wrap_content"
		    android:layout_gravity="right"
		    android:layout_marginRight="30px"
		    android:layout_marginTop="10dp"
		    android:text="Se connecter" />
 
	</LinearLayout>
 
</LinearLayout>
Log Cat :
Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.emergenceit.quiz/fr.emergenceit.quiz.Main}: java.lang.ClassCastException: android.widget.EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
at android.app.ActivityThread.access$2200(ActivityThread.java:119)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.EditText
at fr.emergenceit.quiz.Main.onCreate(Main.java:31)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
Pourriez vous m'aider ?

Merci d'avance pour vos réponses.