Skip to content Skip to sidebar Skip to footer

Android Intent In Dialog Box

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

Solution 1:

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

You have a method to handle the dialog.

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

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
  publicvoidonClick(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();

}

Post a Comment for "Android Intent In Dialog Box"