当我对其他类中的菜单项使用相同的代码时,会显示菜单。但是当我在这个类中实现然后不显示时,谁能告诉我如果我们使用实现 OnClickListener 菜单项是否有任何问题
public class MainPage extends Activity implements OnClickListener {
Context context;
ImageButton countingbutton, maximymbutton, minButton, compareButton,
statsbutton, review, memorygmae;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.newmainpage);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
countingbutton = (ImageButton) findViewById(R.id.countingbutton);
maximymbutton = (ImageButton) findViewById(R.id.maximumbutton);
minButton = (ImageButton) findViewById(R.id.minimunbutton);
compareButton = (ImageButton) findViewById(R.id.comparenum);
statsbutton = (ImageButton) findViewById(R.id.ibStats);
review = (ImageButton) findViewById(R.id.review);
countingbutton.setOnClickListener(this);
maximymbutton.setOnClickListener(this);
minButton.setOnClickListener(this);
compareButton.setOnClickListener(this);
statsbutton.setOnClickListener(this);
review.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate themenu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.cool_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub private static final String
switch (item.getItemId())
{
case R.id.aboutUs:
Intent about = new Intent(this, AboutUs.class);
startActivity(about);
break;
case R.id.exit:
super.finish();
System.exit(0);
break;
case R.id.mainmenu: Intent mainmenu = new Intent(this, MainPage.class);
startActivity(mainmenu);
break;
}
return false;
}