Reputation: 157
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
Upvotes: 0
Views: 5818
Reputation: 454
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();
}
Upvotes: 6