android-dialogfragment

How to correctly dismiss a DialogFragment?

五迷三道 提交于 2019-11-28 03:03:11
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 the dialog is dismissed, instead implement that in onStop() . In my code, all I do is call getDialog().dismiss() to dismiss it. But I am not doing anything else or even using onStop() . So I am asking exactly how to correctly dismiss a DialogFragment to avoid any memory leaks, etc.. tl;dr: The correct way to close a DialogFragment is to use dismiss() directly on the

Fragment must be a public static class to be properly recreated from instance state

守給你的承諾、 提交于 2019-11-27 23:37:00
After updating to the latest support repository, compile 'com.android.support:appcompat-v7:24.2.0' compile 'com.android.support:design:24.2.0' compile 'com.android.support:percent:24.2.0' compile 'com.android.support:recyclerview-v7:24.2.0' I'm getting the weird exception. java.lang.IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state. at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:435) at android.support.v4.app.BackStackRecord.add(BackStackRecord.java:414) at android.support.v4.app.DialogFragment.show

Android DialogFragment onViewCreated not called

痞子三分冷 提交于 2019-11-27 22:00:29
问题 I am using android compatibility library (v4 revision 8). In the custom DialogFragment the overrided method onViewCreated is not getting called.For eg. public class MyDialogFragment extends DialogFragment{ private String mMessage; public MyDialogFragment(String message) { mMessage = message; } @Override public Dialog onCreateDialog( Bundle savedInstanceState){ super.onCreateDialog(savedInstanceState); Log.d("TAG", "onCreateDialog"); setRetainInstance(true); //....do something } @Override

Communication between fragments/dialogs in android

会有一股神秘感。 提交于 2019-11-27 21:52:18
问题 I have an activity with two fragments: one for showing products in a grid view, and the other to show the products that the user adds to the order (ListFragment). When the user clicks a product in the grid view, what I need is to display a dialog (DialogFragment) in which I ask the quantity of product wanted. Then, when the user clicks Accept in the dialog, I want the product to appear in the ListFragment. On one hand, I have to pass the product object to the dialog in order to show its name

Using getFragmentManager() vs getSupportFragmentManager()?

时间秒杀一切 提交于 2019-11-27 20:35:55
When should I use getFragmentManager() when showing DialogFragments, and when should I use getSupportFragmentManager()? Currently, I am showing my DialogFragments as follows: myDialogFragment.show(getFragmentManager(), "My Dialog Fragment"); Itzik Samara If you are using API >= 14, then use getFragmentManager() and while using Support Package you have to use getSupportFragmentManager() For Example Android Support Package v4 or v13. When you are using android.support.v4.app.FragmentManager then you should use getSupportFragmentManager() and if you are using android.app.FragmentManager then use

Why is Android O failing with “does not belong to this FragmentManager!”

我的梦境 提交于 2019-11-27 19:21:12
I have migrated my application to Android O in Android Studio 3 Running on an Android O emulator all my dialogFragments now fail with :- java.lang.IllegalStateException: Fragment MyDialogFragment{43ccf50 #2 MyDialogFragment} declared target fragment SettingsFragment{ceed549 #0 id=0x7f0f0142 android:switcher:2131689794:0} that does not belong to this FragmentManager! at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1316) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1624) at android.support.v4.app.FragmentManagerImpl

DialogFragment fullscreen shows padding on sides

社会主义新天地 提交于 2019-11-27 19:02:13
I am creating a custom DialogFragment that is displayed underneath the actionbar. So far everything works great. The layout parameters for dialog fragment are match_parent for width and wrap_content for height. I have tried every solution including setting the layout parameters .width and by getting Display size and removing the themes. However no matter what there is a small amount of space on left, right and top side of the dialog that is invisible. I need to know how to remove this space so it actually matches the width of the screen and hopefully gets rid of the top padding as well. I

DialogFragment advantages over AlertDialog [duplicate]

萝らか妹 提交于 2019-11-27 17:35:09
This question already has an answer here: Android DialogFragment vs Dialog 7 answers 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: http://developer.android.com/reference/android/app/DialogFragment.html People also say they prefer this here: Android DialogFragment vs Dialog I would like to know the advantages of this approach, since the code becomes more complex. Thanks Tobrun Use DialogFragment over Dialog: Since the

How to make DialogFragment width to Fill_Parent

亡梦爱人 提交于 2019-11-27 17:16:41
Hello 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 AddNoteDialogFragment() { // Empty constructor required for DialogFragment } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().setTitle(getString(R.string.app_name)); View view = inflater.inflate(R.layout.fragment_add_note_dialog, container); return view; } @Override public Dialog

Can't make the custom DialogFragment transparent over the Fragment

限于喜欢 提交于 2019-11-27 17:16:34
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 linearLayout that has curved edges, no matter what i do, the dialog has a black bordering on all sides (very small). I've tried everything to make it transparent and go away (so that all of the dialog is just the linear layout - curved box) For the DialogFragment, this is what I have for onCreateView @Override public View onCreateView(LayoutInflater