当我按菜单显示我的方法时有可能吗?
当我按下设备中的菜单时,我只想显示并关闭此对话框
这个方法菜单播放
private void menuplay(){
final Dialog dialog = new Dialog(this,R.style.Theme_Dialog_costum01);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_play);
dialog.findViewById(R.id.button_play).setOnTouchListener(
new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
dialog.dismiss();
//do method
return true;
}
});
dialog.findViewById(R.id.button_highscore).setOnTouchListener(
new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
dialog.dismiss();
highscoreview();
return true;
}
});
dialog.findViewById(R.id.button_hint).setOnTouchListener(
new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
dialog.dismiss();
hint();
return true;
}
});
dialog.findViewById(R.id.button_about).setOnTouchListener(
new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
dialog.dismiss();
aboutview();
return true;
}
});
dialog.show();
}
我正在尝试这个但不工作
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menuplay();
return true;
}