android-dialogfragment

Cannot get DialogFragment to dismiss programmatically

浪尽此生 提交于 2019-12-01 06:46:28
I have a DialogFragment that shows a list of items to pick from (similar to the attach dialog in Messaging). My problem is that I cannot get this dialog to dismiss when an item is selected. I've tried calling dismiss() and getDialog().dismiss() inside the OnItemClickListener , no luck. I've tried to remove the dialog through the FragmentManager, I've tried fragmentManager.popBackStack() , all to no avail. I cannot get this dialog to dismiss. It goes away fine when clicking outside the dialog or hitting the back button, but nothing in my code will make it go away. Has anyone seen this before?

Soft Keyboard Doesnt show when using adapter in DialogFragment

狂风中的少年 提交于 2019-12-01 06:20:49
问题 I have a custom DialogFragment which has an ArrayAdapter in it which has some editTexts in it. When the dialog is shown the soft keyboard does not appear even if i press on the edit text. The edit text does take focus but the keyboard never comes up. If i do not use an adapter and just use a view with an edit text it works perfectly but as soon as i add the adapter i get the issue. My code is below. Any help would be really appreciated. Thanks in Advance. public class ParameterDialog extends

DialogFragment argument and nullpointer exception

删除回忆录丶 提交于 2019-12-01 06:10:42
My class should pass an argument to DialogFragment, but my app crashes inside onCreate method (of dialog class) for a NullPointerException. Dialog fragment class portion of code: public class ConfirmDialog extends DialogFragment { public ConfirmDialog() {} ConfirmDialog newInstance(String f) { ConfirmDialog d = new ConfirmDialog(); Bundle args = new Bundle(); args.putString("FILE_NAME", f); d.setArguments(args); return d; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); file = getArguments().getString("FILE_NAME"); } I have the nullpointer at

Custom Dialog Fragment

依然范特西╮ 提交于 2019-12-01 06:08:22
I am trying to create a simplistic dialog similar to a DatePickerDialog . The Dialog that I am creating should provide the user with an array of images from which they can select. I believe I have managed to create the array and add the correct images to it, the problem I am running into now is how to get the Dialog to show up? What should I be returning? I have looked into AlertDialogs and such, but I am not sure as to what to do to implement them. UPDATED: FIXED PROBLEM, CODE SHOWN BELOW IS FUNCTIONING PICTURE PICKER public class PicturePickerFragment extends DialogFragment { ArrayList

DialogFragment argument and nullpointer exception

白昼怎懂夜的黑 提交于 2019-12-01 04:40:18
问题 My class should pass an argument to DialogFragment, but my app crashes inside onCreate method (of dialog class) for a NullPointerException. Dialog fragment class portion of code: public class ConfirmDialog extends DialogFragment { public ConfirmDialog() {} ConfirmDialog newInstance(String f) { ConfirmDialog d = new ConfirmDialog(); Bundle args = new Bundle(); args.putString("FILE_NAME", f); d.setArguments(args); return d; } @Override public void onCreate(Bundle savedInstanceState) { super

Is there an equivalent for dispatchTouchEvent() from Activity in Dialog or DialogFragment

无人久伴 提交于 2019-12-01 04:32:07
问题 I need to intercept all touch events in the application to monitor for a custom activity time out. Currently I use dispatchTouchEvent() in my activities but this is not called if I have a dialog on the screen. Does any one know if there any way I can have this same functionality with a dialog being present? Thanks 回答1: For use dispatchTouchEvent() in DialogFragment, override onCreateDialog and return a custom Dialog with dispatchTouchEvent (in your custom DialogFragment). Exemple, for dismiss

Is it possible to launch a DialogFragment from a Preference in a PreferenceActivity?

家住魔仙堡 提交于 2019-12-01 03:24:12
I am converting my app to use the v4 compatibility package and fragments. I have done well so far, but I need to launch a DialogFragment from a preference click in a PreferenceActivity . Since there isn't a PreferenceFragment in the compatibility library, I'm stuck with using PreferenceActivity . Is it possible to get a reference to the fragment manager and call the DialogFragment or do I just have to continue using the old dialog if I need a dialog from a preference? Not without jumping through hoops. You could make a very simple activity with the sole purpose of launching the DialogFragment.

getText from a EditText in a DialogFragment

喜欢而已 提交于 2019-12-01 02:25:27
问题 I have a DialogFragment like this one The Dialog is called by clicking on the "plus" button in the MainActivity below which is initially empty. When I click on "continue", I create a button and so far it works. I also wish that the string I insert in the EditText in DialogFragment is shown on the button I've just created. My problem is that I can not retrieve the string I entered in the EditText. Here is the code: MainActivity public class MainActivity extends FragmentActivity implements

notifyDataSetChanged fails to update ListView

偶尔善良 提交于 2019-12-01 02:24:20
问题 I have a DialogFragment which has a list view with CheckedTextView and a checkbox at the top to Check and uncheck all the items in the list view. I am trying to set the State of the CheckedTextView to Checked/Unchecked depending on the state of the CheckAll Check box. But i am not able to update the view accordingly using notifyDataSetChanged. CategoriesDialogFragment.java public class CategoriesDialogFragment extends SherlockDialogFragment { CheckBox checkAll; ListView categoriesListView;

BottomSheetDialogFragment - listen to dismissed by user event

这一生的挚爱 提交于 2019-12-01 02:23:24
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 touch outside) @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog d = super.onCreateDialog(savedInstanceState); d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { BottomSheetDialog d = (BottomSheetDialog) dialog; FrameLayout bottomSheet = (FrameLayout) dialog