這是我的問題。我創建了一個按鈕ID:「fibo1」。此按鈕屬於「CList」活動。單擊按鈕時,我想打開一個名爲「」斐波那契」的在Android應用程序中點擊一個按鈕打開新的活動
XML另一活動「欄列表的Java上打開「列表中的應用崩潰的
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/fibo1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="sendMessage"
android:text="Fibo" />
欄列表
public class CList extends Activity {
Button read1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
read1 = (Button) findViewById (R.id.fibo1);
read1.setOnClickListener (new OnClickListener(){
@Override
public void onClick (View v){
Intent intent = new Intent (CList.this,Fibonacci.class);
startActivity (intent);
finish();
}
});
}
'Log Activity給出錯誤Fatal Exception :main
。 我已經將這兩項活動都添加到了Android Manifest中。 我只是一個初學者,所以請原諒我,如果我的術語不正確
這裏是登錄貓
03-07 19:33:29.931: E/AndroidRuntime(19565): FATAL EXCEPTION: main
03-07 19:33:29.931: E/AndroidRuntime(19565): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.geek.cprogramspopular/com.geek.cprogramspopular.CList}: java.lang.NullPointerException
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.access$700(ActivityThread.java:150)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.os.Handler.dispatchMessage(Handler.java:99)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.os.Looper.loop(Looper.java:137)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.main(ActivityThread.java:5283)
03-07 19:33:29.931: E/AndroidRuntime(19565): at java.lang.reflect.Method.invokeNative(Native Method)
03-07 19:33:29.931: E/AndroidRuntime(19565): at java.lang.reflect.Method.invoke(Method.java:511)
03-07 19:33:29.931: E/AndroidRuntime(19565): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
03-07 19:33:29.931: E/AndroidRuntime(19565): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
03-07 19:33:29.931: E/AndroidRuntime(19565): at dalvik.system.NativeStart.main(Native Method)
03-07 19:33:29.931: E/AndroidRuntime(19565): Caused by: java.lang.NullPointerException
03-07 19:33:29.931: E/AndroidRuntime(19565): at com.geek.cprogramspopular.CList.onCreate(CList.java:23)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.Activity.performCreate(Activity.java:5283)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
03-07 19:33:29.931: E/AndroidRuntime(19565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
03-07 19:33:29.931: E/AndroidRuntime(19565): ... 11 more
發佈您的logcat .. –
發佈日誌輸出? – mach
發佈完整的代碼和錯誤日誌 –