Mon application s’arrête directement après l'exécution
Bonjour je suis débutant en programmation android, j'ai un problème , quand je lance mon application sur l’émulateur et même sur mon téléphone ça s’arrête directement et m'affiche le fameux message (Sorry....). j'ai aucune idée d'ou vient l'erreur.J'espère que vous m'aiderez, voici un extrait de mon code:
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
| public class MenuActivity extends Activity
{
public boolean onCreateOptionsMenu(Menu paramMenu)
{
getMenuInflater().inflate(R.menu.menu, paramMenu);
return super.onCreateOptionsMenu(paramMenu);
}
public boolean onOptionsItemSelected(MenuItem paramMenuItem)
{
switch (paramMenuItem.getItemId())
{
default:
return super.onOptionsItemSelected(paramMenuItem);
case R.id.new_document :
newDocument();
return true;
case R.id.open_document:
openDocument();
return true;
case R.id.help_document:
helpDocument();
return true;
}
}
public boolean onPrepareOptionsMenu(Menu paramMenu)
{
super.onPrepareOptionsMenu(paramMenu);
return true;
}
}
public class UltimeNote extends MenuActivity
{
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
setContentView(R.layout.main);
}
} |
et voici mon code menu.xml;
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?xml version="1.0" encoding="UTF-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:icon="@drawable/document_new"
android:id="@+id/new_document"
android:title="New">
</item>
<item android:icon="@drawable/document_open"
android:id="@+id/open_document"
android:title="Open">
</item>
<item android:icon="@drawable/document_help"
android:id="@+id/help_document"
android:title="Help">
</item>
</menu> |
et mon code main.xml
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
| <?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:gravity="center"
android:orientation="vertical"
android:id="@+id/appentry"
android:background="@color/dark_blue"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:gravity="center"
android:id="@+id/logo"
android:background="@color/dark_blue"
android:padding="3.0px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/note_logo">
</ImageView>
<TextView android:textStyle="italic"
android:gravity="center"
android:text="memo" >
</TextView>
<View android:background="@color/dark_blue"
android:layout_width="2.0dip"
android:layout_height="2.0dip">
</View>
<TextView android:gravity="center"
android:text="Use Main Options Menu \n to Select Action">
</TextView>
</LinearLayout> |
et voici mon fichier manifest:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ultimanote"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="UltimeNote"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest> |