2014-02-22 67 views
0

我想要一個佈局按鈕來切換用戶到一個新的活動。當我按下按鈕時,它會引發致命錯誤。意圖拋出致命錯誤

第一 - 在這裏是我的.java按鈕:

public class MainActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     Button viewAbout = (Button) findViewById(R.id.buttonAbout); 

     // //onClickListeners// // 

     viewAbout.setOnClickListener(new OnClickListener() { 

      public void onClick(View v) { 

       Intent i = new Intent(MainActivity.this, About.class); 
       startActivity(i); //This is line 50 
            //This is line 51 where the logcat will refer 
      }      // This is line 52 
     }); 
    } 
} 

下面是我收到的logcat:

02-22 12:44:22.095: E/AndroidRuntime(2743): FATAL EXCEPTION: main 
02-22 12:44:22.095: E/AndroidRuntime(2743): Process: biz.midl.debteliminator, PID: 2743 
02-22 12:44:22.095: E/AndroidRuntime(2743): android.content.ActivityNotFoundException: Unable to find explicit activity class {biz.midl.debteliminator/biz.midl.debteliminator.About}; have you declared this activity in your AndroidManifest.xml? 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.Activity.startActivityForResult(Activity.java:3424) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.Activity.startActivityForResult(Activity.java:3385) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.Activity.startActivity(Activity.java:3627) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.Activity.startActivity(Activity.java:3595) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at biz.midl.debteliminator.MainActivity$1.onClick(MainActivity.java:51) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.view.View.performClick(View.java:4438) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.view.View$PerformClick.run(View.java:18422) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.os.Handler.handleCallback(Handler.java:733) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.os.Handler.dispatchMessage(Handler.java:95) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.os.Looper.loop(Looper.java:136) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at android.app.ActivityThread.main(ActivityThread.java:5017) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at java.lang.reflect.Method.invoke(Method.java:515) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
02-22 12:44:22.095: E/AndroidRuntime(2743):  at dalvik.system.NativeStart.main(Native Method) 

回答

1

雖然打字,我意識到,我的Manifest.xml沒有更新:以下聲明我的About.java

 <activity 
     android:name="biz.midl.debteliminator.About" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen" > 
     <intent-filter> 
      <action android:name="android.intent.action.ABOUT" /> 

     </intent-filter> 
    </activity> 

有了這個更新 - 應用程序現在可以工作。

+0

所以它現在有效嗎? – tritop