android-dialogfragment

What is lifecycle of DialogFragment

扶醉桌前 提交于 2019-11-29 13:47:38
问题 I could not find proper lifecycle of android.support.v4.app.DialogFragment by searching on Google. I need this for some implementation. As we know DialogFragment has some methods same like Dialog . DialogFragment extends Fragment so its lifecycle is same as Fragment . But what about other methods of DialogFragment ? Here is Fragment lifecycle. Can one provide for DialogFragment ? 回答1: DialogFragment life cycle is similar to the life cycle of fragment: . To test yourself put logs in each of

Trying to set text of EditText from DatePicker DialogFragment

送分小仙女□ 提交于 2019-11-29 12:45:23
I am simply trying to get the date from a datepicker dialog I created from one of the many android datepicker tutorials I found online. I seem to be going wrong somewhere in the actual retrieving of the text date once it is selected. I have a DatePickerFragment class, which is called from a CreateEvent fragment which is nested inside my MainActivity activity class. This is the DatePicker: public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { private EditText txtDate; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the

Return values from DialogFragment

梦想的初衷 提交于 2019-11-29 11:49:14
I am doing task in which I need to show a dialog after clicking on EditText . In that dialog I show contents with RadioButton s using RecyclerView . Now, what I want to do is, after selecting RadioButton (content which is in the RecyclerView) from dialog, it should return value of that content and then dialog should be dismissed. To generate a dialog I've used a DialogFragment . As I'm new in android development, I am totally confused and unable to find the solution. Because your dialog is a DialogFragment you can use two things If you are starting the dialog from a Activity , you can use an

How to execute action after DialogFragment positive button clicked

白昼怎懂夜的黑 提交于 2019-11-29 09:33:22
问题 I created the following DialogFragment deriving it from the Android documentation: public class PayBillDialogFragment extends DialogFragment{ @Override public Dialog onCreateDialog(Bundle savedInstanceState){ final Bundle b = this.getArguments(); // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Paga bollettino") .setPositiveButton("Paga", new DialogInterface.OnClickListener() { public void

Retrieve and set data from DialogFragment (DatePicker)

萝らか妹 提交于 2019-11-29 08:05:53
My DialogFragment class is invoked when I press a button on a activity. I want the date set through this DialogFragment to be displayed on the buttons text. FindViewById refuses to be recognized by the class. I found a similar question but I'm unable to relate it to my case. Code: Button which calls the Dialogue fragment: public void datepicker(View v) { DialogFragment newFragment = new DatePickerFragment(); newFragment.show(getFragmentManager(), "datePicker"); } Code for dialogue fragment: public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {

Android fragment show as dialogfragment or usual fragment

微笑、不失礼 提交于 2019-11-29 07:21:28
问题 What I am trying to achieve is to have a fragment that on tablet it shows as a DialogFragment , while on smartphone it would be shown as a regular fragment. I am aware there is already a similar post, but I am not able to make that work - apply the style to fragment. To show things top down, MainActivity.java: public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity

Why use newInstance for DialogFragment instead of the constructor?

你说的曾经没有我的故事 提交于 2019-11-29 07:05:05
问题 Looking at the documentation of DialogFragment , one sees the static newInstance method to initialize a new alert dialog fragment. My question is, why not use a constructor to do so, like this: public MyAlertDialogFragment(int title) { Bundle args = new Bundle(); args.putInt("title", title); setArguments(args); } Isn't this exactly the same or does it differ somehow? What's the best approach and why ? 回答1: If you overload the constructor with MyAlertDialogFragment(int title) , the Android

Android DialogFragment onViewCreated not called

為{幸葍}努か 提交于 2019-11-29 02:55:32
I am using android compatibility library (v4 revision 8). In the custom DialogFragment the overrided method onViewCreated is not getting called.For eg. public class MyDialogFragment extends DialogFragment{ private String mMessage; public MyDialogFragment(String message) { mMessage = message; } @Override public Dialog onCreateDialog( Bundle savedInstanceState){ super.onCreateDialog(savedInstanceState); Log.d("TAG", "onCreateDialog"); setRetainInstance(true); //....do something } @Override public void onViewCreated(View view, Bundle savedInstanceState) { Log.d("TAG", "onViewCreated"); //...do

Android DialogFragment onViewCreated not called

∥☆過路亽.° 提交于 2019-11-29 02:53:42
I am using android compatibility library (v4 revision 8). In the custom DialogFragment the overrided method onViewCreated is not getting called.For eg. public class MyDialogFragment extends DialogFragment{ private String mMessage; public MyDialogFragment(String message) { mMessage = message; } @Override public Dialog onCreateDialog( Bundle savedInstanceState){ super.onCreateDialog(savedInstanceState); Log.d("TAG", "onCreateDialog"); setRetainInstance(true); //....do something } @Override public void onViewCreated(View view, Bundle savedInstanceState) { Log.d("TAG", "onViewCreated"); //...do

DialogFragment throws ClassCastException if called from Fragment

这一生的挚爱 提交于 2019-11-29 02:24:10
My DialogFragment throws ClassCastException if called from Fragment, while it is working normally if called from an Activity. I have already looked at few other questions with similar problem and basically those are related to imports, but I haven't been able to solve it in my implementation. Here is my implementation for DialogFragment. import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; public class HotspotScanDialog extends DialogFragment { SetupHotspotDialogListener mListener; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { ...