dialogfragment

Android Dialog Fragments and onActivityResult

喜夏-厌秋 提交于 2019-12-11 03:42:53
问题 I have created an application that presents the user with a dialog fragment with two options: Yes and No . Should the user select 'Yes', the app will call a Zxing barscan application that is installed on the device, and return the result. Now, I have a proof of concept for this working. However this proof of concept uses a simple Activity. Therefore I can achieve this Barscan result using activity, not with Dialog Fragment. The code used in the proof of concept is as follows: public void

How to remove an item from recyclerView after removing it from database

安稳与你 提交于 2019-12-10 18:37:17
问题 I am using a recyclerView to display a list of items that can be deleted when user clicks on delete button of each item. In order to do that, i've used a recyclerview adapter. What i want: From that recycleView adapter, when user clicks on delete button for an item, a dialog fragment is shown and user has to enter a code when that code is valid then the item is removed from both the database and the recyclerView What i've tried: After calling the show() method on the dialogFragment in the

Android: support DialogFragment with custom layout not shown

风格不统一 提交于 2019-12-10 17:16:08
问题 I've had a subclass of DialogFragment ( android.support.v4.app.DialogFragment ) in my app that worked fine for a long time. The dialog itself was constructed in onCreateDialog() callback. Now, however, I want to transition to a new dialogs layout and decided to construct a completely customized dialog. To my best knowledge, this requires removing override of onCreateDialog() and inflating a View hierarchy in onCreateView() callback. I did so. The resulting behavior is very strange - when the

Up ActionBar action on DialogFragment

谁说我不能喝 提交于 2019-12-09 16:32:55
问题 I have a DialogFragment that is styled to full screen using setStyle(STYLE_NORMAL, R.style.Theme_App) . The DialogFragment shows fine but the up action (the homeAsUp action on the ActionBar) does not work. I tried implementing onOptionsItemSelected in the DialogFragment but it is never called. Is there a way to get the up action callback in the DialogFragment so I can dismiss it ? For reference, I'm using ActionBarCompat . 回答1: There is no way to attach an ActionBar to the DialogFragment even

Fullscreen DialogFragment overlaps with StatusBar

青春壹個敷衍的年華 提交于 2019-12-08 16:12:22
问题 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 { @Inject CreateAccountViewModel viewModel; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //InjectDependencies.... View rootView = createDataBinding(inflater, container); createToolbar

Android: disable DialogFragment OK/Cancel buttons

拜拜、爱过 提交于 2019-12-08 15:24:31
问题 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 MyAlertDialogFragment extends DialogFragment { public static MyAlertDialogFragment newInstance(int title) { MyAlertDialogFragment frag = new MyAlertDialogFragment(); Bundle args = new Bundle(); args.putInt("title", title); frag.setArguments(args); return frag; }

Dialogs and Popups in Android

让人想犯罪 __ 提交于 2019-12-08 15:17:14
问题 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 DialogFragment class and Toasts by means of the Toast class. However it's not clear to me whether Popups should be implemented with PopupWindow or with DialogFragment . I know that DialogFragments usually come with Ok/Cancel buttons and that the location of

How to dismiss a DialogFragment without going back to last item in stack

五迷三道 提交于 2019-12-08 14:03:32
问题 In trying to clean up code in an existing project and remove warnings about calling showDialog() in an Activity, I have moved a bunch of related dialogs which show up in a sequence into a new DialogFragment class. It's working OK, however when I press the cancel button on a given dialog, it always takes me back to the previous dialog (which was saved to the back stack), whereas I want the cancel button to dismiss all of the Dialogs and go back to the View in the main activity. Pressing the

How to pass data between multiple Fragments in Android

筅森魡賤 提交于 2019-12-08 07:33:23
问题 In my main Activity, I have a DialogFragment that contains a FragmentTabHost. I have two tabs, one that is a DialogFragment and one that is a ListFragment. When either the 'OK' button is pressed in the inner DialogFragment or when an element in the ListFragment is pressed, I want to pass two Strings (that are entered in two TextView's in the inner DialogFragment and are displayed in each element in the ListFragment) back to the Activity, but I am unsure of how to do this with multiple levels

Starting DialogFragment from a class extending RecyclerView.ViewHolder

╄→尐↘猪︶ㄣ 提交于 2019-12-06 06:00:43
问题 I tried as below at onClick() method of recyelerview.viewholder class. SampleDialogFragment used in the sample extends DialogFragment. @Override public void onClick(View v) { SampleDialogFragment df= new SampleDialogFragment(); df.show(v.getContext().getSupportFragmentManager(), "Dialog"); } I'm facing problem at v.getContext().getSupportFragmentManager() . I can't call getSupportFragmentManager(). I also tried as below . @Override public void onClick(View v) { SampleDialogFragment df= new