2012-04-01 81 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

相關問題