我一直在學習新的波士頓教程的android編程,並且我在教程#27上,並且我陷入了困境。Android編程[新的波士頓教程沒有27]
當我嘗試打開startplay活動時,它不會打開。該程序關閉,說應用程序停止響應。
我試過所有可能的調整,它仍然無法正常工作。
我一直停留在這一點,因爲這兩天/
的Manifest.xml
是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.thenewboston"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="14" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
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=".StartingPoint"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.thenewboston.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.thenewboston.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TextpLay"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.thenewboston.Textplay" />
</intent-filter>
</activity>
</application>
</manifest>
的menu
是:
package com.example.thenewboston;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Menu extends ListActivity{
String classes[]= {"StartingPoint","Textplay","example2","example3","example4","example5","example6"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String cheese=classes[position];
try{
Class<?> ourClass= Class.forName("com.example.thenewboston."+ cheese);
Intent ourIntent= new Intent(Menu.this, ourClass);
startActivity(ourIntent);
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
堆棧跟蹤或logcat的輸出是:
07-15 19:04:56.508: W/dalvikvm(572): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
07-15 19:04:56.558: E/AndroidRuntime(572): FATAL EXCEPTION: main
07-15 19:04:56.558: E/AndroidRuntime(572): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.thenewboston/com.example.thenewboston.Textplay}; have you declared this activity in your AndroidManifest.xml?
07-15 19:04:56.558: E/AndroidRuntime(572): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.app.Activity.startActivityForResult(Activity.java:3190)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.app.Activity.startActivity(Activity.java:3297)
07-15 19:04:56.558: E/AndroidRuntime(572): at com.example.thenewboston.Menu.onListItemClick(Menu.java:30)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.widget.AdapterView.performItemClick(AdapterView.java:292)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.widget.AbsListView.performItemClick(AbsListView.java:1058)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2514)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.widget.AbsListView$1.run(AbsListView.java:3168)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.os.Handler.handleCallback(Handler.java:605)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.os.Handler.dispatchMessage(Handler.java:92)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.os.Looper.loop(Looper.java:137)
07-15 19:04:56.558: E/AndroidRuntime(572): at android.app.ActivityThread.main(ActivityThread.java:4340)
07-15 19:04:56.558: E/AndroidRuntime(572): at java.lang.reflect.Method.invokeNative(Native Method)
07-15 19:04:56.558: E/AndroidRuntime(572): at java.lang.reflect.Method.invoke(Method.java:511)
07-15 19:04:56.558: E/AndroidRuntime(572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-15 19:04:56.558: E/AndroidRuntime(572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-15 19:04:56.558: E/AndroidRuntime(572): at dalvik.system.NativeStart.main(Native Method)
歡迎StackOverflow上的。爲了能夠幫助您,請包含異常堆棧跟蹤。另外,請儘量避免使用大寫鎖。 –
歡迎來編程!這並不容易。 –
耶現在包括它。 –