public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_settings:
Intent Options = new Intent(this,
Options.class);
this.startActivity(Options);
break;
default:
return super.onOptionsItemSelected(item);
}
return true;
}
我的 onOptionsItemSelected() 没有将我发送到我设置的活动。它只是让我回到上一个屏幕。没有错误或任何东西,只是把我踢回屏幕?我也在清单文件中声明了 Options.class。
有任何想法吗?
编辑:
选项.class
import android.app.Activity;
import android.os.Bundle;
public class Options extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.options);
}
}
main_screen.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_settings"
android:title="@string/menu_settings"
android:orderInCategory="100"
android:showAsAction="never" />
LogCat:只需将我发送到活动,然后立即返回
02-04 12:26:55.494: I/ActivityManager(150): Starting activity: Intent { cmp=com.app.test/.Options } from pid 7978
02-04 12:26:55.504: I/ActivityManager(150): Starting activity: Intent { cmp=com.app.test/.MainScreen (has extras) } from pid 7978