Sucky Posted May 13, 2010 Share Posted May 13, 2010 Bonjour a tous, je tiens avant tout a préciser que je débute, Voici mon problème: Je souhaite passer d'une activity a l'autre via un bouton, cependant, lorsque je clique sur le bouton j'obtiens une erreur de type "Fermeture soudaine de l'application". Que cela soit sur l'émulateur ou un téléphone sous android j'obtiens la même erreur. Voici mes deux activity: package test.aph; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; public class monJeu extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { LinearLayout layout = new LinearLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); Button bt = new Button(this); bt.setText("Accede a la deuxieme activity"); bt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(monJeu.this, test.class); startActivity(intent); } }); layout.addView(bt); setContentView(layout); super.onCreate(savedInstanceState); } } et la deuxieme: package test.aph; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; public class test extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { LinearLayout layout = new LinearLayout(this); layout.setLayoutParams(new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); Button bt = new Button(this); bt.setText("Reviens a la premiere"); bt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(test.this, monJeu.class); startActivity(intent); } }); layout.addView(bt); setContentView(layout); super.onCreate(savedInstanceState); } } Je pense que je dois passer a coté de quelque chose de très important, mais je ne vois pas quoi >< Link to comment Share on other sites More sharing options...
zeroot Posted May 13, 2010 Share Posted May 13, 2010 tu as quoi dans les logs? Link to comment Share on other sites More sharing options...
Sucky Posted May 13, 2010 Author Share Posted May 13, 2010 Je viens a l'instant de trouver la solution, le probleme venait de mon AndroidManifest.xml, Merci beaucoup ! Link to comment Share on other sites More sharing options...
naholyr Posted May 13, 2010 Share Posted May 13, 2010 Si ce n'est pas trop indiscret, peux-tu partager le problème en question et sa solution, ça pourrait aider ceux qui tombent sur le même problème :) Link to comment Share on other sites More sharing options...
Sucky Posted May 13, 2010 Author Share Posted May 13, 2010 En fait, je pensais que le Java suffisait a faire le switch entre deux activity en oubliant totalement l'importance du fichier AndroidManifest, j'ai donc simplement declaré l'existence de mon Activity de cette manière: <?xml version="1.0" encoding="utf-8"?> package="app.pkg" android:versionCode="1" android:versionName="1.0"> android:label="@string/app_name"> android:label="@string/app_name"> Une fois fait, j'ai enfin pu naviguer entre les 2 activity. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.