An Android Fragment that displays a dialog window, floating on top of its activity's window.
Questions tagged [dialogfragment]
472 questions
100
votes
14 answers
Detect back button but don't dismiss dialogfragment
I have a dialogfragment for a floating dialog which includes a special keyboard that pops up when a user presses inside an EditText field (the normal IME is stopped from being displayed).
I would like the keyboard to be dismissed (visibility = GONE)…

user3227652
- 1,001
- 2
- 7
- 4
73
votes
2 answers
DialogFragment advantages over AlertDialog
When developing an Android app, I've read that it's recommended to use DialogFragment instead of using directly an AlertDialog to show alerts and confirmations.
This is done, for example, on DialogFragment's Documentation:…

Raphael Petegrosso
- 3,870
- 2
- 24
- 27
64
votes
9 answers
BottomSheetDialogFragment - listen to dismissed by user event
How can I listen to a FINAL dismissal of a BottomSheetDialogFragment? I want to save user changes on the final dismissal only...
I tried following:
Method 1
This only fires, if the dialog is dismissed by swiping it down (not on back press or on…

prom85
- 16,896
- 17
- 122
- 242
50
votes
6 answers
Change DialogFragment enter/exit transition at just before dismissing
I have a DialogFragment and I set animation for enter/exit in the onActivityCreated method as below:
@Override
public void onActivityCreated(Bundle arg0) {
super.onActivityCreated(arg0);
getDialog().getWindow()
…

Dominic D'Souza
- 961
- 2
- 7
- 16
40
votes
4 answers
commitAllowingStateLoss on DialogFragment
I have an IllegalStateException on showing a DialogFragment :
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
i know why its happening but i want to using commitAllowingStateLoss on showing dialog by…

Arash GM
- 10,316
- 6
- 58
- 76
36
votes
1 answer
How to correctly use Android View Binding in DialogFragment?
What is correct way of using Android View Binding in DialogFragment()?
Official documentation mentions only Activity and Fragment:
https://developer.android.com/topic/libraries/view-binding

Valeriya
- 1,067
- 2
- 16
- 31
36
votes
6 answers
getViewLifecycleOwner() in DialogFragment leads to crash
I use DialogFragment (onCreateDialog) and ViewModel for it. But, when I try to pass getViewLifecycleOwner() to the LiveData::observe method I get the error below:
java.lang.IllegalStateException: Can't access the Fragment View's LifecycleOwner when…

Alex.Marynovskyi
- 1,264
- 3
- 16
- 22
29
votes
3 answers
What is lifecycle of DialogFragment
I could not find proper lifecycle of android.support.v4.app.DialogFragment by searching on Google. I need this for some implementation. As we know DialogFragment has some methods same like Dialog.
DialogFragment extends Fragment so its lifecycle is…

Khemraj Sharma
- 57,232
- 27
- 203
- 212
20
votes
8 answers
Get value from Bottom Sheet Dialog Fragment
I'm starting bottomSheetDialogFragment from a fragment A.
I want to select the date from that bottomSheetDialogFragment then set it in the fragment A.
The select date is already done, I just want to get it in the fragment A to set it in some…

Abdulrahman
- 301
- 1
- 3
- 12
19
votes
2 answers
Dialog Fragment with wrap_content coming as a full screen. How to make it as a height of layout and not a full screen?
I have created a custom dialog fragment and its xml as follows:

ravindra.kamble
- 1,023
- 3
- 11
- 20
15
votes
2 answers
Android: disable DialogFragment OK/Cancel buttons
How can I disable OK/Cancel button of a DialogFragment when it is created using an AlertDialog ?
I tried calling myAlertDialogFragment.getDialog() but it's always returning null even once the fragment is displayed
public static class…

user1026605
- 1,633
- 4
- 22
- 58
14
votes
8 answers
Hide to show and hide keyboard in DialogFragment
In my dialog fragment, I am able to show the keyboard using
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT STATE_VISIBLE);
but I am not able to hide it on dismiss.
I've tried…

VIN
- 6,385
- 7
- 38
- 77
14
votes
6 answers
DialogFragment without FragmentActivity
Is it possible to use a DialogFragment when using an Activity instead of a FragmentActivity? The show() methods needs a FragmentManager.
I want to implement a Dialog which contains just one EditText, and the tutorials on android developers says I…

Christopher Francisco
- 15,672
- 28
- 94
- 206
13
votes
2 answers
DialogFragment not showing after adding Alert Window
I have a function that when triggered, succesfully displays a DialogFragment with the following code
DialogFragment
DialogFragment dialog;
View dialogView;
Context activityContext;
...
dialog = new DialogFragment(){
@Override public Dialog…

Maw Boc
- 151
- 8
12
votes
4 answers
Fullscreen DialogFragment overlaps with StatusBar
I created a full screen dialog with the official Guide
The problem is, that my Toolbar overlaps with the status bar and I cannot figure out how to solve this.
DialogFragment
public class CreateAccountDialogFragment extends BaseDialogFragment {
…

JDurstberger
- 4,127
- 8
- 31
- 68