【发布时间】:2014-04-24 06:14:59
【问题描述】:
我正在尝试进行警报对话以显示高分点。但我无法在我的对话中添加 textview,高分存储在 textview 中。这是我的代码,当我单击“否”按钮时,我需要显示 textview。
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Your Title");
// set dialog message
alertDialogBuilder
.setMessage("Time is up!")
.setCancelable(false)
.setPositiveButton("Restart!",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, close
// current activity
App2Activity.this.finish();
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
}.start();
【问题讨论】:
-
你的 textView 位于哪里?
-
最终 TextView 得分 = (TextView)findViewById(R.id.textscore); score.setText(" "+counter);
标签: android android-alertdialog dialog