2012-04-01 112 views
0

我想在我的sudoku应用程序中实现第二个菜单,但在模拟器中无法启动。它说:使用第二个菜单?

[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

一个封闭的应用程序重新启动它这必须解决您的问题。它的,因为你的应用程序没有重新开张之前关闭

同时更换这些线路

addPreferencesFromResource(R.xml.settings);

的setContentView(R.xml.settings);

+0

kk我关闭了模拟器中的应用程序,但它所做的只是显示菜单,但没有进入菜单。你知道为什么吗? – maximus 2012-04-01 15:56:30

+0

我没有得到你你可以更具体 – Ishu 2012-04-01 16:00:17

+0

我已经定义了一个settings.xml文件,我有两个复选框。我用我的Prefs Methode调用这个* .xml。但它没有显示任何东西... – maximus 2012-04-01 16:02:41

相关问题