android-dialogfragment

How to set the title of DialogFragment?

只愿长相守 提交于 2019-12-17 21:49:54
问题 This should be a simple task, but for some reason I can find a way to set the title of a DialogFragment. (I am setting the dialog contents using onCreateView overload). The default style leaves a place for the title, but I can't find any method on the DialogFragment class to set it. The title is somehow magically set when the onCreateDialog method is used to set the contents, so I wonder if this is by design, or there is a special trick to set it when using the onCreateView overload. 回答1: You

Show dialog from fragment?

别来无恙 提交于 2019-12-17 08:09:46
问题 I have some fragments that need to show a regular dialog. On these dialogs the user can choose a yes/no answer, and then the fragment should behave accordingly. Now, the Fragment class doesn't have an onCreateDialog() method to override, so I guess I have to implement the dialogs outside, in the containing Activity . It's ok, but then the Activity needs to report back the chosen answer somehow to the fragment. I could of course use a callback pattern here, so the fragment registers itself at

How to create a DialogFragment without title?

懵懂的女人 提交于 2019-12-17 06:59:26
问题 I'm creating a DialogFragment to show some help messages regarding my app. Everything works fine besides one thing: There is a black stripe at the top of the window that shows the DialogFragment, that I presume is reserved for the title, something I don't want to use. This is specially painful since my custom DialogFragment uses a white background, so the change is way too notorious to be left aside. Let me show you this in a more graphical manner: Now the XML code for my DialogFragment is as

DialogFragment and onDismiss

橙三吉。 提交于 2019-12-17 04:56:30
问题 I am using a DialogFragment , which I am showing like this from an Activity : DialogFragmentImage dialog = DialogFragmentImage.newInstance(createBitmap()); dialog.onDismiss(dialog);.onDismiss(this); dialog.show(getFragmentManager(), "DialogFragmentImage"); I would like to check when the DialogFragment was dismissed (for example when the back button was pressed), but in my Activity . How can I do that? How can I "tell" my activity that the DialogFragment has been dismissed? 回答1: Make your

Android DialogFragment vs Dialog

北城以北 提交于 2019-12-17 02:00:54
问题 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? 回答1: 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

Android, reach Button via DialogFragment?

穿精又带淫゛_ 提交于 2019-12-14 04:22:03
问题 What i want: the buttons text is "08:00" now. When click the button it shows a timepicker. The selected time is set to the buttons text. (Alarm app). i have read some tutorials and questions-answers about this, but haven't find the answers yet. After i press the clock button the app crashes. If i put the onCreateView part in comment it works. it says: android.util.AndroidRuntimeException: requestFeature() must be called before adding content. public class TimeSet extends DialogFragment

Should an internal DialogFragment class be static or not?

倾然丶 夕夏残阳落幕 提交于 2019-12-14 03:42:21
问题 This is a snippet of code from my project that I am using to learn Android: private void enableLocationSettings() { Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(settingsIntent); } @SuppressLint("ValidFragment") public class EnableGpsDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setTitle("Tytuł") .setMessage("wiadomosc") .setPositiveButton(

Why isn't onShow in my custom dialogfragment being invoked?

守給你的承諾、 提交于 2019-12-13 07:28:23
问题 I have a custom alertdialog that implements interfaces so that their callbacks can be invoked. I set breakpoints in the first lines of onDismiss and onShow. The dialog pops up and I see all the views, but the breakpoint in onShow does not get hit and my async task does not get created. public class CountdownDialogFragment extends DialogFragment implements OnClickListener, OnShowListener, OnDismissListener { InnerClassAsyncTask myAsyncTask; @Override public Dialog onCreateDialog(Bundle

Eclipse Android missing getSupportFragmentManager and getChildFragmentManager

两盒软妹~` 提交于 2019-12-13 06:02:33
问题 Hi I tried using the android supported lib v4 as well as v13 instead of android app lib but eclipse still cannot recognize the getSupportedFragmentManager and getChildFragmentManager functions. Are there any steps I need to take in order fro eclipse to recognize both functions? Currently using Eclipse luna with latest android sdk, targeting api 17 platform. I need either function to see why the app crashes with no view found for id ?? when using viewpager inside dialogfragment. Thanks in

How to receive the actions made by the user in a DialogFragment?

萝らか妹 提交于 2019-12-13 04:20:56
问题 I have a ListView that displays a list of Contacts. When a contact is clicked, a DialogFragment is created which displays a notice on whether or not to Cancel or Confirm. Based on whether they click Cancel or Confirm I want to change the color of the ListView item. How can I get the status of the Button click for the dialog. My code for the dialog: @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction String first =