我正在尝试在我的数独应用程序中实现第二个菜单,但在模拟器中无法启动。它说:
[2012-04-01 17:43:44 - Sudoku] Android Launch!
[2012-04-01 17:43:44 - Sudoku] adb is running normally.
[2012-04-01 17:43:44 - Sudoku] Performing org.madmax.sudoku.SudokuActivity activity launch
[2012-04-01 17:43:44 - Sudoku] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'em22'
[2012-04-01 17:43:46 - Sudoku] Application already deployed. No need to reinstall.
[2012-04-01 17:43:46 - Sudoku] Starting activity org.madmax.sudoku.SudokuActivity on device emulator-5554
[2012-04-01 17:43:47 - Sudoku] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=org.madmax.sudoku/.SudokuActivity }
[2012-04-01 17:43:47 - Sudoku] ActivityManager: Warning: Activity not started, its current task has been brought to the front
这是我的代码:
public void onClick(View v) {
switch(v.getId()) {
case R.id.about_button:
Intent i = new Intent(this, About.class);
startActivity(i);
break;
//more buttons go here!!!
}
}
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
public boolean onOptionItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.settings:
startActivity(new Intent(this, Prefs.class));
return true;
}
return false;
}
答案 0 :(得分:0)
一个关闭应用程序重新启动它必须解决您的问题。这是因为你的应用程序在重新启动之前没有关闭
也替换这些行
addPreferencesFromResource(R.xml.settings);
带
的setContentView(R.xml.settings);