Questions tagged [android-alertdialog]

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.

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)

Reference

5697 questions
55
votes
5 answers

Android Don't dismiss AlertDialog after clicking PositiveButton

Can I just don't dismiss my AlertDialog after clicking PositiveButton? I would like to remain the dialog to show something update on my ArrayAdapter listWords. This is my code. AlertDialog.Builder sayWindows = new…
Yi-Ying Lu
  • 565
  • 1
  • 4
  • 5
54
votes
4 answers

alertDialog.getButton() method gives null pointer exception android

Iam planing to give create 3 buttons with layout_weight=1, not interested in custom dialog.So I have written below code.It is not working.Always yes button gives me null. Whats wrong in this code? AlertDialog dialog= new…
ADIT
  • 2,388
  • 9
  • 34
  • 46
54
votes
10 answers

Change text color of alert dialog

I have a popup for downloading the audio instruction in my app. What I am trying to do is to change the default text color of "OK" to blue. I tried something but it's not working. Here is my code: private void showDownloadPgmPopup() { …
gaurav tiwari
  • 1,093
  • 1
  • 9
  • 28
52
votes
7 answers

Show alert dialog on app main screen load automatically in flutter

I want to show alert dialog based on a condition. Not based on user interaction such as button press event. If a flag is set in app state data alert dialog is shown otherwise its not. Below is the sample alert dialog which I want to show void…
WitVault
  • 23,445
  • 19
  • 103
  • 133
52
votes
7 answers

How to style AlertDialog Actions in Flutter

I use this method to show a AlertDialog: _onSubmit(message) { if (message.isNotEmpty) { showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( …
MeLean
  • 3,092
  • 6
  • 29
  • 43
52
votes
8 answers

How to dismiss AlertDialog in android

I created AlertDialog that contains 4 buttons OptionDialog = new AlertDialog.Builder(this); OptionDialog.setTitle("Options"); LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v…
Emy Alsabbagh
  • 1,087
  • 3
  • 13
  • 22
50
votes
14 answers

Remove black background on custom dialog

I want to remove the black background on custom dialog as shown in the picture. I'm sure the black background was from the dialog, not from app's background. ; AlertDialog code public class MyAlertDialog extends AlertDialog { public…
pengwang
  • 19,536
  • 34
  • 119
  • 168
50
votes
9 answers

Problem inflating custom view for AlertDialog in DialogFragment

I'm trying to create a DialogFragment using a custom view in an AlertDialog. This view must be inflated from xml. In my DialogFragment class I have: @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new…
50
votes
2 answers

Android Dialog theme makes icon too light

I created a new application in Eclipse, targeted to Jelly Bean. This is all automatically created code. The manifest sets the application theme to AppName:
ilomambo
  • 8,290
  • 12
  • 57
  • 106
48
votes
5 answers

Add bigger margin to EditText in Android AlertDialog

I have an EditText inside an AlertDialog. It looks like this. See where it says tddjdjck and how it is indented quite a lot. That is what I want (I used setPadding with left and right set to 50), but I also want the blue line under it to be…
b85411
  • 9,420
  • 15
  • 65
  • 119
48
votes
7 answers

How to get selected item of a singlechoice Alert Dialog?

I have this code to show a dialog with singlechoice(radio) options. AlertDialog ad = new AlertDialog.Builder(this) .setCancelable(false) .setIcon(R.drawable.alert_dialog_icon) .setTitle(R.string.choose_one) .setSingleChoiceItems(seq,…
Pentium10
  • 204,586
  • 122
  • 423
  • 502
46
votes
7 answers

Changing font size into an AlertDialog

I am trying to put some loooong text into an AlertDialog. The only issue the default font size that is really too big, so I want to make it smaller. Here are all the workaround I tried and their issues. Workaround 1) Using a TextView and…
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
46
votes
9 answers

set Transparent background to alertdialog in android

I want to show an alert dialog with a transparent background. My code for the alert dialog is: AlertDialog.Builder imageDialog = new AlertDialog.Builder(SubProducts.this); LayoutInflater inflater =…
Neeha
  • 727
  • 3
  • 9
  • 21
45
votes
5 answers

How to select a entry in AlertDialog with single choice checkbox android?

I have an alert dialog with a single-choice list and two buttons: an OK button and a cancel button. The code below show how I implemented it. private final Dialog createListFile(final String[] fileList) { AlertDialog.Builder builder = new…
LuckyStarr
  • 1,468
  • 2
  • 26
  • 39
43
votes
11 answers

How do I display a dialog in android without an Activity context?

This seems like it should be simple, but I'm not finding an answer anywhere. I have an Android application that performs network tasks in the background. If an error comes back, I want to display an error dialog. When the task returns, I don't…
ManicBlowfish
  • 2,258
  • 2
  • 21
  • 29