Best code examples for Android AlertDialog class (android.app.AlertDialog)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AlertDialog class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android AlertDialog examples from Open Source projects
Examples using Android AlertDialog setButton method:
This code example shows how to use the following methods: setButton, setMessage, setTitle, dismiss, isShowing
66:	if (dialog.isShowing()) { 
67:	dialog.dismiss(); 
-
71:	dialog.setButton(DialogInterface.BUTTON_POSITIVE, 
-
74:	dialog.setTitle(title); 
75:	dialog.setMessage(message); 
76:	dialog.show(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setButton, setTitle, setProgressStyle, show
141:	progressDialog   =  new ProgressDialog(context); 
142:	progressDialog.setTitle("Update software"); 
-
144:	progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 
145:	progressDialog.setButton("Cancel", new OnClickListener() { 
-
155:	progressDialog.show(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setButton, setTitle, setProgressStyle, show
141:	progressDialog   =  new ProgressDialog(context); 
142:	progressDialog.setTitle("Update software"); 
-
144:	progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 
145:	progressDialog.setButton("Cancel", new OnClickListener() { 
-
155:	progressDialog.show(); 
Full Snippet Info
8
CodeRank
Examples using Android AlertDialog setTitle method:
This code example shows how to use the following methods: setTitle, setIndeterminate, setMessage, setCancelable, setOnCancelListener
36:	ProgressDialog progressDialog = new ProgressDialog(context); 
37:	progressDialog.setTitle(title); 
38:	progressDialog.setMessage(message); 
39:	progressDialog.setIndeterminate(indeterminate); 
40:	progressDialog.setCancelable(cancelable); 
41:	progressDialog.setOnCancelListener(onCancelListener); 
42:	progressDialog.show(); 
43:	Robolectric.getShadowApplication().setLatestAlertDialog(shadowOf(progressDialog)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setTitle, setIndeterminate
29:	ProgressDialog dialog = new ProgressDialog(getActivity()); 
30:	dialog.setIndeterminate(true); 
31:	dialog.setTitle(title); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setTitle, setIndeterminate, setMessage, setCancelable
67:	ProgressDialog dialog = new ProgressDialog(this); 
68:	dialog.setTitle("Indeterminate"); 
69:	dialog.setMessage("Please wait while loading..."); 
70:	dialog.setIndeterminate(true); 
71:	dialog.setCancelable(true); 
Full Snippet Info
8
CodeRank
Examples using Android AlertDialog setIcon method:
This code example shows how to use the following methods: setIcon, setMessage, setTitle, setCancelable, show
49:	new DatePickerDialog(Ch09DateTimeDialog.this, 
-
53:	datePicDlg.setTitle("輸入日期"); 
54:	datePicDlg.setMessage("請輸入日期"); 
55:	datePicDlg.setIcon(android.R.drawable.ic_dialog_info); 
56:	datePicDlg.setCancelable(false); 
57:	datePicDlg.show(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setIcon, setTitle, setIndeterminate, setMessage, setProgressStyle
88:	progressDialog = new ProgressDialog(activity); 
89:	progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); 
90:	progressDialog.setIcon(android.R.drawable.ic_dialog_info); 
91:	progressDialog.setTitle("Carregando..."); 
92:	progressDialog.setMessage("Obtendo palestras, aguarde..."); 
93:	progressDialog.setCancelable(false); 
94:	progressDialog.setIndeterminate(true); 
95:	progressDialog.show(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setIcon, setTitle, setMax, setMessage, setProgressStyle
20:	mProgressDialog = new ProgressDialog(mContext); 
21:	mProgressDialog.setTitle("Checking dependencies"); 
22:	mProgressDialog.setMessage("Please wait..."); 
23:	mProgressDialog.setCancelable(false); 
24:	mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 
25:	mProgressDialog.setMax(100); 
26:	mProgressDialog.setIcon(0); 
Full Snippet Info
7
CodeRank
Examples using Android AlertDialog setMessage method:
This code example shows how to use the following methods: setButton, setMessage, setTitle, show
80:	msgDialog.show(); 
-
86:	msgDialog.setTitle(title); 
87:	msgDialog.setMessage(msg); 
88:	msgDialog.setButton(buttonText, new DialogInterface.OnClickListener(){ 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setMessage, show
185:	mOptionNoteDialog.setMessage( mOptions[item] ); 
186:	mOptionNoteDialog.show(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setMessage, setTitle, show
77:	mDialog.setTitle(title); 
78:	mDialog.setMessage(getText(message)); 
79:	mDialog.show(); 
Full Snippet Info
7
CodeRank
Examples using Android AlertDialog getButton method:
This code example shows how to use the following methods: getButton
578:	applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON1)); 
579:	applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON2)); 
580:	applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON3)); 
581:	applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON_NEGATIVE)); 
582:	applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON_NEUTRAL)); 
583:	applyButtonStyle(ctx, dialog.getButton(DialogInterface.BUTTON_POSITIVE)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getButton, getWindow
100:	mDialog.getWindow() 
-
103:	mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); 
Full Snippet Info
6
CodeRank
Examples using Android AlertDialog getListView method:
This code example shows how to use the following methods: getListView, show
81:	dialog.getListView().setOnItemLongClickListener( longClickListener ); 
82:	dialog.show(); 
Full Snippet Info
6
CodeRank
Related Android AlertDialog Questions & Answers:
Other Android AlertDialog Examples
0:	AlertDialog alertDialog = new AlertDialog.Builder(
1:							AlertDialogActivity.this).create();
2:

Read More

7:				// device doesn't support flash
8:				// Show alert message and close the application
9:				AlertDialog alert = new AlertDialog.Builder(MainActivity.this)
10:						.create();
11:				alert.setTitle("Error");

Read More

17:		public void showAlertDialog(Context context, String title, String message,
18:				Boolean status) {
19:			AlertDialog alertDialog = new AlertDialog.Builder(context).create();
20:	
21:			// Setting Dialog Title

Read More

AlertDialog Class Overview
A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. If you want to display a more complex view, look up the FrameLayout called "custom" and add your view to it:

FrameLayout fl = (FrameLayout) findViewById(android.R.id.custom); fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT)); The AlertDialog class takes care of automatically setting WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM for you based on whether any views in the dialog return true from View.onCheckIsTextEditor(). Generally you want this set for a Dialog without text editors, so that it will be placed on top of the current input method UI. You can modify this behavior by forcing the flag to your desired mode after calling onCreate(Bundle). Developer Guides For more information a...
Methods
  • getButton
    Gets one of the buttons used in the dialog.
  • setButton
    This method was deprecated in API level 3. Use setButton(int, CharSequence, Message) with BUTTON_POSITIVE.
  • setTitle
    Set the title text for this dialog's window.