Questions tagged [android-dialogfragment]

DialogFragment is a fragment that displays a dialog window, floating on top of its activity's window.

DialogFragment is a fragment that displays a dialog window, floating on top of its activity's window. Also BottomSheetDialogFragment is a version of it which shows a bottom sheet instead of a floating dialog.

DialogFragment reference
BottomSheetDialogFragment reference

1948 questions
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…
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
368
votes
7 answers

How to create a DialogFragment without title?

I'm creating a DialogFragment to show some help messages regarding my app. Everything works fine besides one thing: There is a black stripe at the top of the window that shows the DialogFragment, that I presume is reserved for the title, something I…
AlejandroVK
  • 7,373
  • 13
  • 54
  • 77
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
204
votes
31 answers

Full Screen DialogFragment in Android

I'm trying to show an almost fullscreen DialogFragment. But I'm somehow not able to do so. The way I am showing the Fragment is straight from the android developer documentation FragmentManager f =…
Eric
  • 2,053
  • 2
  • 13
  • 6
184
votes
18 answers

Callback to a Fragment from a DialogFragment

Question: How does one create a callback from a DialogFragment to another Fragment. In my case, the Activity involved should be completely unaware of the DialogFragment. Consider I have public class MyFragment extends Fragment implements…
eternalmatt
  • 3,524
  • 4
  • 25
  • 25
166
votes
7 answers

How to set the title of DialogFragment?

This should be a simple task, but for some reason I can find a way to set the title of a DialogFragment. (I am setting the dialog contents using onCreateView overload). The default style leaves a place for the title, but I can't find any method on…
StefanK
  • 2,020
  • 2
  • 14
  • 16
137
votes
13 answers

How to correctly dismiss a DialogFragment?

The docs say this for the dismiss() method from the Dialog class: Dismiss this dialog, removing it from the screen. This method can be invoked safely from any thread. Note that you should not override this method to do cleanup when…
Andy
  • 10,553
  • 21
  • 75
  • 125
134
votes
6 answers

passing argument to DialogFragment

I need to pass some variables to DialogFragment, so I can perform an action. Eclipse suggests that I should use Fragment#setArguments(Bundle) But I don't know how to use this function. How can I use it to pass variables to my dialog?
giozh
  • 9,868
  • 30
  • 102
  • 183
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
123
votes
21 answers

How to change background color of the snackbar?

I am showing snackbar in a DialogFragment within the positive touch of the alert dialog. Here is my code snippet: Snackbar snackbar = Snackbar.make(view, "Please enter customer name", Snackbar.LENGTH_LONG) .setAction("Action",…
123
votes
6 answers

DialogFragment setCancelable property not working

I am working in an android application and am using a DialogFragment to show a dialog and I want to make that DialogFragment not cancelable. I have made the dialog cancelable property to false, but still its not affecting. Please look into my code…
Arun PS
  • 4,610
  • 6
  • 41
  • 56
119
votes
11 answers

Can't make the custom DialogFragment transparent over the Fragment

I need to create a dialog over a fragment (that takes up the whole screen). The dialog needs to be a floating dialog that will be positioned over the fragment with the fragment darkened out outside of the fragment.. For the custom Dialog, i have a…
118
votes
21 answers

How to make DialogFragment width to Fill_Parent

I am working on an android application where I am using DialogFragment to display the dialog but its width is very small. How I can make this width to fill_parent to it ? public class AddNoteDialogFragment extends DialogFragment { public…
N Sharma
  • 33,489
  • 95
  • 256
  • 444
1
2 3
99 100