Questions tagged [android-dialog]

Base class for Dialogs. A dialog in Android is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.

A dialog is usually a small window that appears in front of the current Activity. The underlying Activity loses focus and the dialog accepts all user interaction. Dialogs are normally used for notifications that should interrupt the user and to perform short tasks that directly relate to the application in progress (such as a progress bar or a login prompt).

Official Android Dialog Documentation

1460 questions
1212
votes
38 answers

How do I display an alert dialog on Android?

I want to display a dialog/popup window with a message to the user that shows "Are you sure you want to delete this entry?" with one button that says 'Delete'. When Delete is touched, it should delete that entry, otherwise nothing. I have written a…
UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278
812
votes
21 answers

How to prevent a dialog from closing when a button is clicked

I have a dialog with EditText for input. When I click the "yes" button on dialog, it will validate the input and then close the dialog. However, if the input is wrong, I want to remain in the same dialog. Every time no matter what the input is, the…
536
votes
28 answers

How to handle screen orientation change when progress dialog and background thread active?

My program does some network activity in a background thread. Before starting, it pops up a progress dialog. The dialog is dismissed on the handler. This all works fine, except when screen orientation changes while the dialog is up (and the…
Heikki Toivonen
  • 30,964
  • 11
  • 42
  • 44
406
votes
21 answers

How to create a Custom Dialog box in android?

I want to create a custom dialog box like below I have tried the following things. I created a subclass of AlertDialog.Builder and used a custom Title and Custom Content View and used that but the result was not as expected. Another attempt was…
Amit
  • 13,134
  • 17
  • 77
  • 148
309
votes
16 answers

Android 1.6: "android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application"

I'm trying to open a dialog window, but every time I try to open it it throws this exception: Uncaught handler: thread main exiting due to uncaught exception android.view.WindowManager$BadTokenException: Unable to add window -- token null is…
295
votes
25 answers

Dialog with transparent background in Android

How do I remove the black background from a dialog box in Android. The pic shows the problem. final Dialog dialog = new Dialog(Screen1.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.themechanger);
Programmer
  • 5,360
  • 10
  • 37
  • 61
290
votes
11 answers

How to show a dialog to confirm that the user wishes to exit an Android Activity?

I've been trying to show a "Do you want to exit?" type of dialog when the user attempts to exit an Activity. However I can't find the appropriate API hooks. Activity.onUserLeaveHint() initially looked promising, but I can't find a way to stop the…
Peter A
  • 2,919
  • 2
  • 16
  • 4
279
votes
10 answers

Android Activity as a dialog

I have an Activity named whereActity which has child dialogs as well. Now, I want to display this activity as a dialog for another activity. How can I do that?
d-man
  • 57,473
  • 85
  • 212
  • 296
272
votes
10 answers

Android DialogFragment vs Dialog

Google recommends that we use DialogFragment instead of a simple Dialog by using Fragments API, but it is absurd to use an isolated DialogFragment for a simple Yes-No confirmation message box. What is the best practice in this case?
skayred
  • 10,603
  • 10
  • 52
  • 94
225
votes
30 answers

How to set DialogFragment's width and height?

Let's say I specify the layout of my DialogFragment in an xml layout file named my_dialog_fragment.xml and I specify the layout_width and layout_height values of its root view to a fixed value (e.g. 100dp). I then inflate this layout in my…
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
214
votes
20 answers

How to make custom dialog with rounded corners in android

What I am trying to do: I am trying to make a custom dialog in android With rounded corners. What is happening: I am able to make custom dialog but it doesn't have rounded corners. I tried adding a selector but still I couldn't achieve rounded…
Devrath
  • 42,072
  • 54
  • 195
  • 297
177
votes
14 answers

How to dismiss the dialog with click on outside of the dialog?

I have implemented a custom dialog for my application. I want to implement that when the user clicks outside the dialog, the dialog will be dismissed. What do I have to do for this?
Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
134
votes
12 answers

Android 'Unable to add window -- token null is not for an application' exception

I get the following Android exception when I try to open a dialog. Can someone please help me understand what is going on and how can I fix this problem? android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for…
michael
  • 106,540
  • 116
  • 246
  • 346
128
votes
5 answers

How can I add a third button to an Android Alert Dialog?

The API says that the Alert Dialog can have one, two or three buttons, but the SDK only allows for a positive and negative button. How then can I add a third button?
user180825
123
votes
7 answers

Show dialog from fragment?

I have some fragments that need to show a regular dialog. On these dialogs the user can choose a yes/no answer, and then the fragment should behave accordingly. Now, the Fragment class doesn't have an onCreateDialog() method to override, so I guess…
Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101
1
2 3
97 98