Here is a simple use of AlertDialog:
AlertDialog alertDialog = new AlertDialog.Builder(theContext).create(); alertDialog.setTitle("End Game?"); alertDialog.setMessage("Are you sure you wish to end the game?"); alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { finish(); } }); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); alertDialog.show();
I thought that I would add what I did after I came across this page, as it would be useful for me to see !! - Hope this helps the next guy or girl :-)
source share