У меня есть действие под названием GameViewUI.В этом упражнении у меня есть этот метод:
int DIALOG_GAMEOVER_ID = 1;
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_GAMEOVER_ID:
Context mContext = this;
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.gameoverdialog);
dialog.setTitle("GAME OVER");
TextView text = (TextView) dialog
.findViewById(R.id.pointsGameOverTextView);
text.setText("Points: " + currentScore);
// Get buttons and add listeners
Button playAgainButton = (Button) dialog
.findViewById(R.id.playAgainButton);
Button goToMainMenuButton = (Button) dialog
.findViewById(R.id.goToMainMenuButton);
playAgainButton.setOnTouchListener(this);
goToMainMenuButton.setOnTouchListener(this);
return dialog;
}
return super.onCreateDialog(id);
}
Как и этот:
public boolean onTouch(View view, MotionEvent event) {
if (view.equals((Button) findViewById(R.id.goToMainMenuButton))) {
Intent myIntent = new Intent(view.getContext(), MainUI.class);
startActivity(myIntent);
return true;
}
}
При запуске этого кода появляется диалоговое окно:
showDialog(1);
Появляется диалоговое окно, и я вижу кнопки.Но они не кликабельны!Я не могу щелкнуть их.
Что я делаю не так?
Я хочу нажимать кнопки и переходить к другим действиям.
Пожалуйста, помогите.