質問

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();

}

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top