Android的意图对话框 [英] Android Intent in Dialog box

查看:137
本文介绍了Android的意图对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Andr​​oid开发者,所以我需要你的帮助。我在做一个应用程序,其中一个按钮动作打开一个对话框。对话框中有一个按钮。我可以一心想按钮操作?请给一些好的可能的方式。谢谢

I'm new android developer so I need your help. I'm making a app in which a button action open a dialog box. Dialog box has a button. Can i intent on the button action? Kindly give some good possible ways. Thanks

推荐答案

您要处理的确定事件,并执行一些动作。

you want to handle the "Ok" event and perform some action.

您必须处理对话框的方法。

You have a method to handle the dialog.

public void displayAlertToChangeActivity(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("title");
alert.setMessage("massage");

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int whichButton) {
   //Do something here where "ok" clicked and then perform intent from activity context
   Intent intent = new Intent(MyActivity.this, MyNextActivity.class);
   MyActivity.this.startActivity(intent);

}
});

alert.show();

}

这篇关于Android的意图对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆