Problème d'affichage avec mon application
Hello !
je suis actuellement entrain d'essayer de développer une application pour faciliter l'identification d'insectes et aussi pour apprendre a développer une application pour android.
Tous se passe bien au début mon émulateur m'affiche bien mon premier layout mais je n'arrive pas à cliquer sur un bout afin d'afficher le deuxième layout. Pourriez vous m'aider ?
le main :
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
| package android.Choix;
import android.R;
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.Toast;
public class Main extends Activity implements OnClickListener
{
private static final int INSECTES = 0;
public Button [] listeBoutons = new Button[1];
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(0x7f030000);
listeBoutons[INSECTES] = ((Button)this.findViewById(0x7f050001));
}
public void onClick(View v){
String msg="";
int parametre = v.getId();
creerAcrivite (parametre);
switch (parametre){
case 0x7f050001 :
msg = "Insectes";
break;
case 0x7f050002:
msg ="Plantes";
break;
}
Toast msgT = Toast.makeText(this,msg,Toast.LENGTH_SHORT);
msgT.show();
}
public void creerAcrivite(int activite){
Intent nvActivite ;
switch (activite){
case INSECTES:
nvActivite = new Intent (Main.this, Coleoptera.class);
startActivityForResult(nvActivite, INSECTES);
}
}
} |
qui lance le layout accueil :
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
| <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF"
android:id="@+id/accueil"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/insectes"
android:id="@+id/insectes"
android:layout_marginTop="2px"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/plantes"
android:id="@+id/plantes"
android:layout_marginTop="2px"
/>
</LinearLayout> |
qui lui devrait ensuite lancer le coleoptera.java
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
| package android.Choix;
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;
/**
*
* @author Asus
*/
public class Coleoptera extends Activity implements OnClickListener{
private static final int POLYPHAGA = 0;
private static final int ADEPHAGA = 1 ;
public Button [] listeBoutons = new Button[1];
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(0x7f030001);
listeBoutons[POLYPHAGA] = ((Button)this.findViewById(0x7f050005));
listeBoutons[ADEPHAGA] = ((Button)this.findViewById(0x7f050004));
}
public void onClick(View v){
int parametre = v.getId();
//creerAcrivite (parametre);
}
/* public void creerAcrivite(int activite){
Intent nvActivite ;
switch (activite){
case POLYPHAGA:
nvActivite = new Intent (Main.this, Polyphaga.class);
startActivityForResult(nvActivite, INSECTES);
}
nvActivite = new Intent (Main.this, Coleoptera.class);
startActivityForResult(nvActivite, INSECTES);
}
*/
} |
qui lui même appelle le layout coleoptera
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
| <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFFFF"
android:id="@+id/Coleoptera"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/adephaga"
android:layout_marginTop="5px"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hanches postérieures dépassant le bord postérieur du premier segment abdominal visible"
android:id="@+id/Adephaga"
android:layout_marginTop="2px"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/polyphaga"
android:layout_marginTop="5px"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hanches postérieures ne dépassant pas le bord postérieur du premier segment abdominal visible"
android:id="@+id/Polyphaga"
android:layout_marginTop="2px"
/>
</LinearLayout> |
pour finir mon fichier manifest
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.Choix"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name="Main"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Coleoptera"
android:label="Choisir une option"
/>
</application>
</manifest> |
Voilà j'imagine que mon erreur est toute simple mais je ne la trouve ...
Pourriez vous m'aider ou il vous faut plus d'info ?
PS: j'ai mis directement l'adresse des fichiers car le R.id.(nom du fichier) ne marche pas.