onCreate中的Android意图错误
即使我以前做过,我的意图也不起作用。下拉菜单提供四个选项卡。其中一个链接应该会将您带到应用程序中的教程页面。因此,在选项菜单中,当在页面上单击教程时,它会调用教程意图。在错误日志中,它告诉您字符串:它走了这么远。但是,它并没有告诉您:它离发布在这里的第二个活动上的onCreate方法有这么远 需要对我的意图代码进行哪些更改才能将其连接起来onCreate中的Android意图错误,android,android-intent,Android,Android Intent,即使我以前做过,我的意图也不起作用。下拉菜单提供四个选项卡。其中一个链接应该会将您带到应用程序中的教程页面。因此,在选项菜单中,当在页面上单击教程时,它会调用教程意图。在错误日志中,它告诉您字符串:它走了这么远。但是,它并没有告诉您:它离发布在这里的第二个活动上的onCreate方法有这么远 需要对我的意图代码进行哪些更改才能将其连接起来 public void tutorialIntent() //toasts and takes you to the settings... { L
public void tutorialIntent() //toasts and takes you to the settings...
{
Log.e("tutorialintent I", "It got this far");
Intent in = new Intent(MainActivity.this, tutorial.class);
startActivity(in);
setResult(Activity.RESULT_OK);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) { //since int IDS are 1-4
case 1:
Log.e("test", "tutorial intent pressed");
tutorialIntent();
return true;
case 2: //clear
settingsIntent();
return true;
case 3:
aboutIntent();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
这是TUTORIAL.JAVA活动的ONCREATE代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.e("tutorialintent I", "It got this far I");
super.onCreate(savedInstanceState);
Log.e("tutorialintent I", "It got this far II");
setContentView(R.layout.tutorial);
Log.e("tutorialintent I", "It got this far III");
}
您是否在AndroidManifest.xml中添加了教程活动?由于有人刚刚发布并删除了他/她的评论,必须将该活动放入AndroidManifest文件中
<activity
android:name="com.jakegosskuehn.couchto5k.settings"
android:label="@string/app_name" >
</activity>
您的清单文件是什么样子的?抱歉,Jayizzle,没有看到其他人的评论。我模仿了他/她吗?我对你的两条评论投了赞成票,所以你应该恢复正常。
<activity
android:name="com.jakegosskuehn.couchto5k.settings"
android:label="@string/app_name" >
</activity>