Basic AlertDialog Using Tutorial

1. The following is the sample code to use alert dialog in an android application:

    public void warningmessage(AlertDialog.Builder alertDialogBuilder, String str,int titleId)
    {
    	alertDialogBuilder.setMessage(str);
    	alertDialogBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				
			}
		});
		AlertDialog alertDialog = alertDialogBuilder.create();
                // set the title for the dialog
		alertDialog.setTitle(titleId);
                // Set the Icon for the Dialog
                alertDialog.setIcon(R.drawable.icon);
                alertDialog.show();
    }

SourceCode Here

For more information please visit the following:
http://androidtrainningcenter.blogspot.in/2012/07/how-to-create-custom-and-default-alert.html
Happy alerting 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s