android-dialogfragment

DialogFragment with clear background (not dimmed)

我怕爱的太早我们不能终老 提交于 2019-11-26 13:01:05
问题 I\'m trying to get the background of a DialogFragment to be completely clear. With setting the style item android:windowIsFloating to true (the default), the DialogFragment displays exactly how I want it to, but has a very dimmed background. By setting android:windowIsFloating to false, I get the clear background I want, but the DialogFragment blows up to about 95% of the screen, leaving only a tiny gap around it where you can see through to the view it overlays. I\'ve tried ton\'s of tweaks

AlertDialog with custom view: Resize to wrap the view's content

对着背影说爱祢 提交于 2019-11-26 12:18:48
问题 I have been having this problem in an application I am building. Please ignore all of the design shortcomings and lack of best practice approaches, this is purely to show an example of what I cannot solve. I have DialogFragment which returns a basic AlertDialog with a custom View set using AlertDialog.Builder.setView() . If this View has a specific size requirement, how do I get the Dialog to correctly resize itself to display all of the content in the custom View ? This is the example code I

Fragment inner class should be static

时光毁灭记忆、已成空白 提交于 2019-11-26 10:24:36
问题 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

Position of DialogFragment in Android

会有一股神秘感。 提交于 2019-11-26 10:14:36
问题 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. 回答1: 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 =

Callback to a Fragment from a DialogFragment

喜夏-厌秋 提交于 2019-11-26 09:41:28
Question: How does one create a callback from a DialogFragment to another Fragment. In my case, the Activity involved should be completely unaware of the DialogFragment. Consider I have public class MyFragment extends Fragment implements OnClickListener Then at some point I could do DialogFragment dialogFrag = MyDialogFragment.newInstance(this); dialogFrag.show(getFragmentManager, null); Where MyDialogFragment looks like protected OnClickListener listener; public static DialogFragment newInstance(OnClickListener listener) { DialogFragment fragment = new DialogFragment(); fragment.listener =

How to change the background color around a DialogFragment?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 09:28:54
问题 I\'m building a custom DialogFragment . The dialog layout is set to my_dialog.xml , but how can I modify the color around the dialog (the transparent grey)? my_dialog.xml <RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_gravity=\"center\" > <TextView android:id=\"@+id/hello\" android:layout_width=\"100dp\" android:layout_height=\"100dp\" android:background=\"@android:color

Android DialogFragment vs Dialog

谁都会走 提交于 2019-11-26 09:28:53
Google recommends that we use DialogFragment instead of a simple Dialog by using Fragments API , but it is absurd to use an isolated DialogFragment for a simple Yes-No confirmation message box. What is the best practice in this case? PJL Yes, use DialogFragment and in onCreateDialog you can simply use an AlertDialog builder anyway to create a simple AlertDialog with Yes/No confirmation buttons. Not very much code at all. With regards handling events in your fragment there would be various ways of doing it but I simply define a message Handler in my Fragment , pass it into the DialogFragment

ActionBar in a DialogFragment

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 06:12:44
问题 In the Calendar app on my Galaxy Tab 10.1, when creating a new event a dialog comes up with Done and Cancel buttons in the title bar/action bar area. I\'d like to implement this in my app. I\'ve tried using setHasOptionsMenu(true) in addition to overriding onCreateOptionsMenu in my DialogFragment subclass, but my action items do not appear. I\'ve also tried calling getDialog().getActionBar() from within onCreateView but it always returns null . I am able to get this working if I start an

passing argument to DialogFragment

我与影子孤独终老i 提交于 2019-11-26 05:19:39
问题 I need to pass some variables to DialogFragment , so I can perform an action. Eclipse suggests that I should use Fragment#setArguments(Bundle) But I don\'t know how to use this function. How can I use it to pass variables to my dialog? 回答1: Using newInstance public static MyDialogFragment newInstance(int num) { MyDialogFragment f = new MyDialogFragment(); // Supply num input as an argument. Bundle args = new Bundle(); args.putInt("num", num); f.setArguments(args); return f; } And get the Args

How to set DialogFragment&#39;s width and height?

自作多情 提交于 2019-11-26 04:58:57
问题 I specify the layout of my DialogFragment in an xml layout file (let\'s call it layout_mydialogfragment.xml ), and its layout_width and layout_height attributes particularly (to be 100dp each let\'s say). I then inflate this layout in my DialogFragment\'s onCreateView(...) method as follows: View view = inflater.inflate(R.layout.layout_mydialogfragment, container, false); Unfortunately, I find that when my dialog (DialogFragment) appears, it does not respect the layout_width and layout_height