private AlertDialog.Builder alert()
{
AlertDialog.Builder myQuittingDialogBox =new AlertDialog.Builder(this);
myQuittingDialogBox.setTitle("your title");
myQuittingDialogBox.setMessage("set Msg Here");
myQuittingDialogBox.setIcon(R.drawable.yourimg);
myQuittingDialogBox.setPositiveButton("yes"), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
// your code here
dialog.dismiss();
}
});
myQuittingDialogBox.setNeutralButton("no"), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//write your code here
dialog.dismiss();
}
});
myQuittingDialogBox.create();
return myQuittingDialogBox;
}
呼び出し
AlertDialog.Builder diaBox = alert();
diaBox.show();