Questions tagged [dialogfragment]

An Android Fragment that displays a dialog window, floating on top of its activity's window.

444 questions
81
votes
9 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
  • 811
  • 1
  • 6
  • 4
70
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:…
46
votes
5 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() …
42
votes
6 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
  • 14,805
  • 15
  • 98
  • 206
35
votes
3 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…
27
votes
4 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
  • 816
  • 1
  • 12
  • 19
22
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…
19
votes
2 answers
17
votes
2 answers

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
Lera
  • 826
  • 1
  • 13
  • 29
16
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
  • 251
  • 1
  • 3
  • 11
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…
13
votes
5 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
  • 13,553
  • 23
  • 77
  • 181
13
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,414
  • 3
  • 22
  • 50
12
votes
1 answer

Dialogs and Popups in Android

The Android design documentation in http://developer.android.com/design/building-blocks/dialogs.html makes a clear differentiation between Dialogs, Alerts, Popups and Toasts. It also recommends the implementation of Dialogs by means of the…
leo9r
  • 1,882
  • 23
  • 28
12
votes
2 answers

Android: NullPointerException at DialogFragment.dismissInternal at DialogFragment.dismissAllow

Crash app when show ProgressDialog. I'm testing on my phone with a slide-out keyboard. When dialog is show I slide keyboard and app crashes. public static class ProgressDialogFragment extends DialogFragment { public ProgressDialogFragment() …
1
2 3
29 30