即使我以前做过,我的意图也行不通。下拉菜单带有四个选项卡。其中一个链接应该带您进入应用程序中的教程页面。所以在optionsmenu中,当在页面上单击教程时,它会调用教程意图。在错误日志中,它会告诉你字符串:“它到目前为止”。但是,它并没有告诉你:“它得到了这么远我”来自onCreate方法的第二个活动(这里发布的代码的最后一个snippit)。
我的意图代码需要进行哪些更改才能将其链接起来。
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);
}
}
public class tutorial extends Activity {
@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");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
menu.add(1, 2, Menu.FIRST +2, "Settings");
menu.add(1, 3, Menu.FIRST +3, "About");
return true;
}
}
这是TUTORIAL.JAVA ACTIVITY的开创性代码:
@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");
}
答案 0 :(得分:0)
您是否在AndroidManifest.xml中添加了教程活动?
答案 1 :(得分:0)
正如有人刚刚发布并删除了他/她的评论,必须将活动放在AndroidManifest文件中。
<activity
android:name="com.jakegosskuehn.couchto5k.settings"
android:label="@string/app_name" >
</activity>