A quick a simple Alert Dialog Popup with Title, Message, Icon and Button
Don't forget to import add the imports
import android.app.AlertDialog;
import android.content.DialogInterface;
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Title");
alertDialog.setMessage("Message");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Add your code for the button here.
}
});
// Set the Icon for the Dialog
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
2 Comments
very useful thanks
A good snippet. However I like chained (or what's proper name for this) calls more. Like: