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
36
votes
6 answers

Dialog buttons with long text not wrapping / squeezed out - material theme on android 5.0 lollipop

While optimizing an app for material theme on lollipop, I'm encountering this annoying problem: Whenever there is long text on dialog buttons, that doesn't fit the button bar width in total, the text isn't wrapped in multiple lines for those buttons…
36
votes
5 answers

Blur Background Behind AlertDialog

As we know from API 14 the Below Blur has been deprecated dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); Is there any alternative for this to make the Screen Blur behind Dialog I have tried FAST blur
Nitesh Tiwari
  • 4,742
  • 3
  • 28
  • 46
35
votes
14 answers

Displaying soft keyboard whenever AlertDialog.Builder object is opened

My code for opening an input dialog reads as follows: final AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Dialog Title"); alert.setMessage("Request information"); LayoutInflater factory =…
prepbgg
  • 3,564
  • 10
  • 39
  • 51
35
votes
2 answers

Android 5.x: Why does Dialog.Builder cuts text off?

I have an issue with the Dialog.Builder, where the Buttons are cut off. How can I resolve this or is this an issue for Motorola devices? making the text shorter is not a solution I expect the same behaviour like the S5-screenshot, Buttons too long…
longi
  • 11,104
  • 10
  • 55
  • 89
35
votes
4 answers

How to use Dialog Fragment? (showDialog deprecated) Android

I understand that there is this documentation http://developer.android.com/reference/android/app/DialogFragment.html#AlertDialog but as a new Android/Java learner it is not easy to understand the amount of code involved from writing a simple alert…
Lion789
  • 4,402
  • 12
  • 58
  • 96
33
votes
2 answers

DialogFragment Class Deprecated in Android P

The Android Documentation gives the following warning. This class was deprecated in API level P. Use the Support Library DialogFragment for consistent behavior across all devices and access to Lifecycle. Does this simply mean that the only…
33
votes
9 answers

Ok Button for Alert Dialog on Android

This is my code for an alert, it shows a message when a button is pressed. How can I make an OK Button to dismiss? Button bm1 = (Button) findViewById(R.id.button1); bm1.setOnClickListener(new View.OnClickListener() { …
berk kaan
  • 447
  • 2
  • 7
  • 12
32
votes
11 answers

Closing a custom alert dialog on button click

I'm having trouble closing my alert dialog. I am using a layout inflator to make the dialog, so I'm not sure how I would go about closing the thing after I'm done with it. Code is below: AlertDialog.Builder dialog = new…
Eric
  • 321
  • 1
  • 3
  • 3
32
votes
6 answers

Activity has leaked window at alertDialog show() method

I am getting window leak error at runtime because of using an AlertDialog. I have pointed out the error line in the code below: Stacktrace: 08-18 02:48:04.489 28893-28893/? E/WindowManager﹕ Activity com.ms.ha.fragment.FirstActivity has leaked…
Steve
  • 1,153
  • 2
  • 15
  • 29
31
votes
5 answers

Android: Difference between positive, negative, and neutral button

Is there a functional difference between positive, negative, and neutral buttons, particularly in the context of AlertDialogs?
bibismcbryde
  • 369
  • 1
  • 5
  • 17
30
votes
8 answers

Button style in AlertDialogs

Does anyone know how to override the default style for AlertDialog buttons? I've looked through the Android source for themes and styles and experimented with different things but I haven't been able to find a way that works. What I've got below…
Steve Haley
  • 55,374
  • 17
  • 77
  • 85
30
votes
1 answer

Where can I find default AlertDialog layout xml file?

I want to make an default Alert Dialog with a small modification. Where can I find an xml layout file of default AlertDialog?
latata
  • 1,703
  • 5
  • 27
  • 57
29
votes
6 answers

Using HTML in Android Alert Dialog

I have some amount of informations to be displayed in Dialog Box. It comes like Title, then under it text; Title, then under it text. Like wise, there are 4 titles and 4 descriptions to be displayed. It should come like this Title…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
29
votes
3 answers

Disable background dim on ProgressDialog/AlertDialog in Android

I use an AsyncTask with a ProgressDialog in it. This automatically causes a background dim of about 40%. I want to turn this dim off (0% dim), but what I tried, didn't work: myLoadingDialog = new…
Day
  • 844
  • 1
  • 9
  • 21
28
votes
11 answers

Android 6.0 Dialog text doesn't appear

I updated my phone to Android 6.0 and I have these 2 problems with dialogs: 1)The title is shown but the messages isn't for alert dialog(SOLVED): new AlertDialog.Builder(context).setTitle("Title").setMessage("Message"); 2)Also custom…