我想在活動課一個TextView點擊開始片段活動,但我得到以下exception.I是新到Android,請help.This是我的代碼.ActivityNotFoundException:無法找到明確的活動類
Intent intent=new Intent(this,ThreeFragment.class);
startActivity(intent);
並得到以下例外。
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.siluni.myapplication/com.example.siluni.myapplication.ThreeFragment}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1791)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1513)
at android.app.Activity.startActivityForResult(Activity.java:3933)
at android.app.Activity.startActivityForResult(Activity.java:3881)
at android.app.Activity.startActivity(Activity.java:4204)
at android.app.Activity.startActivity(Activity.java:4172)
at com.example.siluni.myapplication.SheduleActivity.SaveShedule(SheduleActivity.java:178)
at com.example.siluni.myapplication.SheduleActivity$5.onClick(SheduleActivity.java:150)
at android.view.View.performClick(View.java:5076)
at android.view.View$PerformClick.run(View.java:20279)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5930)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
'ThreeFragment'實際上是一個'Activity'嗎?如果是這樣,你是否在你的堆棧跟蹤的第一行注意到了這個問題? - '你是否在你的AndroidManifest.xml中聲明瞭這個活動?' –
不,我有4個選項卡,這些選項卡actvity是片段活動Tabdisplay活動包含manifest.xml文件中的全部4個tabs.so僅包含tabDisplayactvity –
'Fragment'不是'活動'。你不用'startActivity()'加載'Fragment'。 –