0
package com.guess.phone;

import android.app.Activity;

public class Menu extends Activity {

    // Setting Up the MenuInflater

    public boolean onCreateOptionsMenu(Menu Menu) {
            super.onCreateOptionsMenu((android.view.Menu) Menu);

            MenuInflater awesome = getMenuInflater();    
            awesome.inflate(R.menu.main_menu,(android.view.Menu) Menu);
            return true; 
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()) {
        case R.id.menuSweet:
            startActivity(new Intent("com.guess.phone.SWEET"));
            return true;
        case R.id.menuToast:
            return true;    
        }
        return false;
    }
}
4

1 回答 1

0

改用下面的 OnCreateOptionsMenu

public boolean OnCreateOptionsMenu(Menu menu){
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.main_menu, menu);
   return super.onCreateOptionsMenu(menu);
}
于 2012-08-26T14:19:51.400 回答