android-dialogfragment

Setting the size of a DialogFragment

风格不统一 提交于 2019-11-27 05:19:54
问题 I have been trying many commands to setup the size of my DialogFragment . It only contains a color-picker, so I have removed the background and title of the dialog: getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); getDialog().getWindow().setBackgroundDrawable( new ColorDrawable(android.graphics.Color.TRANSPARENT)); However I also want to position the dialog where I want and it is problematic. I use: WindowManager.LayoutParams params = getDialog().getWindow().getAttributes();

How to correctly dismiss a DialogFragment?

不想你离开。 提交于 2019-11-27 05:02:32
问题 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

Android Alert Dialog unable to find view

风流意气都作罢 提交于 2019-11-27 04:49:52
问题 I'm having trouble getting an AlertDialog to pass text back to the activity that calls it. It seems the issue is that it fails to find the proper EditText when calling findViewByID, but I'm new to Android and don't know why that may be. The code is below: public class ModifyDialogFragment extends DialogFragment { /* The activity that creates an instance of this dialog fragment must * implement this interface in order to receive event callbacks. * Each method passes the DialogFragment in case

DialogFragment advantages over AlertDialog [duplicate]

我是研究僧i 提交于 2019-11-27 04:13:00
问题 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

Can't make the custom DialogFragment transparent over the Fragment

亡梦爱人 提交于 2019-11-27 04:11:06
问题 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

Show DialogFragment from onActivityResult

情到浓时终转凉″ 提交于 2019-11-27 04:09:59
问题 I have the following code in my onActivityResult for a fragment of mine: onActivityResult(int requestCode, int resultCode, Intent data){ //other code ProgressFragment progFragment = new ProgressFragment(); progFragment.show(getActivity().getSupportFragmentManager(), PROG_DIALOG_TAG); // other code } However, I'm getting the following error: Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState Anybody know what's going on, or how I can fix this? I

Custom dialog too small

蹲街弑〆低调 提交于 2019-11-27 03:51:41
问题 I have an android activity that implements a custom dialog.The application is running ok but the dialog is too small,i want to display a bigger dialog.How can i achieve this? Here is my layout xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent

Fragment inner class should be static

这一生的挚爱 提交于 2019-11-27 03:11:34
I have a FragmentActivity class with inner class that should display Dialog . But I am required to make it static . Eclipse offers me to suppress error with @SuppressLint("ValidFragment") . Is it bad style if I do it and what are the possible consequences? public class CarActivity extends FragmentActivity { //Code @SuppressLint("ValidFragment") public class NetworkConnectionError extends DialogFragment { private String message; private AsyncTask task; private String taskMessage; @Override public void setArguments(Bundle args) { super.setArguments(args); message = args.getString("message"); }

Should I use a PopupWindow or DialogFragment for accepting input?

坚强是说给别人听的谎言 提交于 2019-11-27 03:09:19
问题 I am doing a Popup with 3 Spinners and an EditText. After reading many blogs and articles I can't decide which is the best option, PopupWindow or DialogFragment . The criteria would be: Compatibility with different Android's versions Performance If there is a better way to do it I am open to change the perspective. Thank you very much. DialogFragment: Pros: Cons: PopupWindow: Pros: Cons: EDIT: CONCLUSION DialogFragment allows you to use more complex features. Another important thing is that

Position of DialogFragment in Android

雨燕双飞 提交于 2019-11-27 02:45:54
I have a DialogFragment to show a View like a Popup screen. The Window appears always in the middle of the screen. Is there a way to set the position of the DialogFragment window? I have looked in to the source code but couldn't find anything yet. Steelight Try something like this: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); WindowManager.LayoutParams p = getDialog().getWindow().getAttributes(); p.width = ViewGroup.LayoutParams.MATCH_PARENT; p