I created custom dialog fragment to be able use Joda dates type.
Creating of dialog. It's method from my custom DialogFragment.
public Dialog onCreateDialog(Bundle savedInstanceState) {
String title = getArguments().getString(KEY_TITLE, getString(R.string.dg_dp_title));
LocalDate date = (LocalDate) getArguments().getSerializable(KEY_DATE);
if (null == date) date = new LocalDate();
FragmentActivity context = getActivity();
@SuppressLint("InflateParams")
View view = LayoutInflater.from(context).inflate(R.layout.dialog_date_picker, null);
mDatePickerView = (DatePicker) view.findViewById(R.id.dg_dp_picker);
mDatePickerView.updateDate(date.getYear(), date.getMonthOfYear() - 1, date.getDayOfMonth());
return new AppDialogBuilder(context)
.setTitle(title)
.setView(view)
.setPositiveButton(R.string.dg_dp_button_positive, mListener)
.setNegativeButton(R.string.dg_dp_button_negative, mListener)
.create();
}
Layout file.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent">
<DatePicker
android:id="@+id/dg_dp_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:calendarViewShown="true"
android:datePickerMode="calendar"
android:spinnersShown="false"/>
</FrameLayout>
If remove setting title form builder, then dialog will looks fine
But I need to use title. Thoughts?
Aucun commentaire:
Enregistrer un commentaire