android-dialogfragment

OnCancelListener is not called in DialogFragment

守給你的承諾、 提交于 2019-12-03 02:30:55
I have a simple AlertDialog that displays a list of some items and upon clicking one of them, the clicked item is passed back to the enclosing Activity . I also want to perform some default handling when the user cancels the dialog (using the back button ) - more specifically, I want to pass an empty string to the activity in such case. However, if I put the dialog in a DialogFragment (from the compatibility package ), the OnCancelListener is not called when I close the dialog with the back button . What am I doing wrong? public class SelectItemDialog extends DialogFragment { public interface

Custom FragmentDialog with round corners and not 100% screen width

别来无恙 提交于 2019-12-03 02:18:19
问题 I am creating a custom fragment dialog with round corners and with layout that would not fill the screen width (I would prefer if it just wrapped its content). this is my rounded_dialog.xml in drawable folder, which is called by my Custom ThemeWithCorners as a background for the dialog. I also tried to set it as background to the linear layout which creates its content but nothing works. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid

Textview: using the dialog title style: @android:style/TextAppearance.DialogWindowTitle

隐身守侯 提交于 2019-12-03 01:35:09
I am currently trying tu build my own DialogFragment theme. One of my requirement is to use an icon at the right of the title. First idea Simply using: this.getDialog().getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.dialog_title); But unfortunately, this line of code has no result. Second idea Provinding my own layout -this.setContentView()- with this textview: <TextView android:id="@+id/tvTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="From XML" android:textAppearance="@android:style/TextAppearance.DialogWindowTitle" /> This works,

DialogFragment callback on orientation change

被刻印的时光 ゝ 提交于 2019-12-02 21:38:55
I'm migrating my dialogs, currently using Activity.showDialog(DIALOG_ID); , to use the DialogFragment system as discussed in the android reference . There's a question that arose during my development when using callbacks to deliver some event back to the activity/fragment that opened the dialog: Here's some example code of a simple dialog: public class DialogTest extends DialogFragment { public interface DialogTestListener { public void onDialogPositiveClick(DialogFragment dialog); } // Use this instance of the interface to deliver action events static DialogTestListener mListener; public

Getting information from DialogFragment using onDismiss()

笑着哭i 提交于 2019-12-02 21:17:53
问题 I am working on an app and I am using a custom dialog which extends DialogFragment. This dialog will contain certain field that I want to pass to the parent activity. I tried implementing OnDismissListener but the parameter is a Dialog Interface. Any Idea? parent Activity: fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { BreakCreator mDialog = new BreakCreator(); mDialog.show(getSupportFragmentManager(), "start break Creator"); } }); listener:

IllegalStateException: Can not perform this action after onSaveInstanceState with onActivityResult

人盡茶涼 提交于 2019-12-02 20:53:09
问题 I am new to Android development. I got an issue. I tried the last couple of hour but I can't figure out this. if so I got a popular question. IllegalStateException: Can not perform this action after onSaveInstanceState with ViewPager but failed because of the lack of Android development experience. Here is code: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if(resultCode == RESULT_OK) { MyCustomDialogFragment newPopup = new

passing context as argument of DialogFragment

无人久伴 提交于 2019-12-02 18:00:48
it's possible to pass a context variable to a DialogFragment? i've use this code inside dialog for passing a string: public static ConfirmDialog newInstance( String f) { ConfirmDialog d = new ConfirmDialog(); Bundle args = new Bundle(); args.putString("FILE_NAME", f); d.setArguments(args); return d; } but i don't find any function like putString for passing context. It's possible to do that? Your DialogFragment has a very handy method for getting a Context instance: getActivity() Fragment#getActivity() will return the instance of the Activity (which is a Context ) that the Fragment is attached

Error inflating Class fragment in DialogFragment

痞子三分冷 提交于 2019-12-02 17:30:16
问题 I am trying to create a dialogfragment with a listview inside of it and I used the accepted answer from this question to do it How to display an existing ListFragment in a DialogFragment But I am getting an Error inflating class fragment when I try to open the fragment dialog and the app crashes Below is the dialog_fragment_with_list_fragment layout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match

Custom FragmentDialog with round corners and not 100% screen width

不打扰是莪最后的温柔 提交于 2019-12-02 15:49:01
I am creating a custom fragment dialog with round corners and with layout that would not fill the screen width (I would prefer if it just wrapped its content). this is my rounded_dialog.xml in drawable folder, which is called by my Custom ThemeWithCorners as a background for the dialog. I also tried to set it as background to the linear layout which creates its content but nothing works. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@android:color/white"/> <corners android:radius="20dp" /> </shape> and this is how i call the

IllegalStateException: Can not perform this action after onSaveInstanceState with onActivityResult

若如初见. 提交于 2019-12-02 11:52:39
I am new to Android development. I got an issue. I tried the last couple of hour but I can't figure out this. if so I got a popular question. IllegalStateException: Can not perform this action after onSaveInstanceState with ViewPager but failed because of the lack of Android development experience. Here is code: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 1) { if(resultCode == RESULT_OK) { MyCustomDialogFragment newPopup = new MyCustomDialogFragment(); newPopup.setMyClickListener(MainActivity.this); FragmentManager