设置一个按钮作为后退按钮
我想设置一个简单的警报视图的确定按钮来充当后退按钮的作用。我应该使用什么方法?
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this.getContext());
AlertDialog alert = alt_bld.create();
alert.setTitle("Your score is: " + score);
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//here would be the "back button's method"
}});
alert.show();
I would like to setup a simple Alert View's OK button to act as the back button acts. What method should I use?
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this.getContext());
AlertDialog alert = alt_bld.create();
alert.setTitle("Your score is: " + score);
alert.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//here would be the "back button's method"
}});
alert.show();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需添加:
Just add:
您必须调用 finish 方法才能销毁活动。
You have to call the finish method in order to destroy activity.
为此,您的活动和活动中仅此而已单击按钮时调用。
for that just this in your activity & call when button is clicked.