1
當我按菜單顯示我有的方法時,它可能嗎?對話框在設備中按下菜單時變得顯示
我只是想這個對話框顯示和關閉,當我在設備按菜單
這種方法menuplay
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;
}
你按什麼「菜單」?如果它是一個按鈕,請將'menuplay()'放入按鈕的onClick –