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
28
votes
5 answers

AlertDialog: Why can't I show Message and List together?

Does anybody know why the AlertDialog doesn't show the list of items when I add a Message with .setMessage()? The negative and positive buttons will be shown, but not the list. When I delete the line with .setMessage() everything works. This is my…
Alex Feh
  • 331
  • 3
  • 6
28
votes
10 answers

Android Error: Unable to add window -- token null is not for an application

Hy. I tried to create an alert dialog but when I run my application, is throw an exception 09-26 12:43:21.949: E/AndroidRuntime(14618): FATAL EXCEPTION: main 09-26 12:43:21.949: E/AndroidRuntime(14618): android.view.WindowManager$BadTokenException:…
user2576008
  • 499
  • 1
  • 6
  • 15
28
votes
5 answers

AlertDialog Theme: How to change item text color?

When I try to apply a standard theme to AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(MyClass.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); builder.setTitle("Change"); String[] info=…
Mohsen Afshin
  • 13,273
  • 10
  • 65
  • 90
28
votes
4 answers

Android - How do I make this alert dialog scrollable?

I am a beginner in android and making my first android app. my 'About' menu item, when clicked shows an AlertDialog with a really long message. I have been trying different methods to make it scrollable but I couldn't. I have tried reading different…
ashu
  • 1,756
  • 4
  • 22
  • 41
28
votes
5 answers

OnCancelListener is not called in DialogFragment

I have a simple AlertDialog that displays a list of some items and upon clicking one of them, the clicked item is passed back to the enclosing Activity. I also want to perform some default handling when the user cancels the dialog (using the back…
Natix
  • 14,017
  • 7
  • 54
  • 69
27
votes
5 answers

Set Android Theme.Light for Alert Dialog

I am trying to set the android Theme.Light theme for my alert dialog, but with no success so far. After reading a few tutorials I gathered that using AlertDialog.Builder we cannot set the theme directly in the constructor (atleast in API level…
27
votes
6 answers

How can can I add custom buttons into an AlertDialog's layout?

I have AlertDialog with Positive and Negative buttons. In AlertDialog layout I have EditText and two Buttons (btnAdd1, btnAdd2). I want when user click at the Button btnAdd1 or btnAdd2 add same text to EditText in AlertDialog (but no close…
Pepa Zapletal
  • 2,879
  • 3
  • 39
  • 69
26
votes
4 answers

How to change the color of an AlertDialog message?

I have an AlertDialog and it's message is displayed, but the color of the text is white. It blends in with the background. I've tried changing the theme but it doesn't work. How do I change the color of the message? The relevant…
an3
  • 568
  • 1
  • 6
  • 14
25
votes
8 answers

Android AlertDialog with dynamically changing text on every request

I want to show an AlertDialog with one option that might change on every request. So for example at one time I want to show the option "add to contacts" while another time it should be "remove from contacts". My code does work on the first time,…
Ulrich Scheller
  • 11,800
  • 5
  • 28
  • 32
25
votes
6 answers

How can I get the results from an AlertDialog?

I am using an AlertDialog.Builder to display a dialog to prompt the user to enter a password, I then want to save that password in a preference, however I can't figure out how to get the result from the alert dialog's input method. Here is…
finiteloop
  • 4,444
  • 8
  • 41
  • 64
25
votes
2 answers

Let app run in background in android

Hi: I'm curiously about how to show this dialog. When I press allow, the battery optimize is disabled for this app. Is it an new android api
hy fa
  • 551
  • 1
  • 6
  • 10
25
votes
3 answers

AlertDialog Input Text

I'd like to use AlertDialog as a Login or pin code or password dialog. Here is my code - AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Login"); alert.setMessage("Enter Pin :"); …
soclose
  • 2,773
  • 12
  • 51
  • 60
25
votes
14 answers

Change title font of Alert Dialog box

I want to change the font of the title of Alert Dialog box. Can anybody tell how can I do it?
Eagle_Eye
  • 1,044
  • 1
  • 14
  • 26
25
votes
11 answers

Android Dialog - Rounded Corners and Transparency

I'm trying to make a custom android dialog with rounded corners. My current attempts have given me this result. As you can see, the corners are rounded, but it leaves the white corner still intact. Below is the xml that I put in the drawable…
24
votes
3 answers

How to achieve custom dialog at the bottom of the screen in Android

Which component do I choose to achieve custom dialog at the bottom as shown in the below image? Shall I choose alertdialog,popupwindow, or fragmentdialog?