android-datepicker

DatePickerDialog always opens the current date

霸气de小男生 提交于 2019-12-13 05:32:17
问题 I am having trouble with a DatePickerDialog , everytime I open it shows the current date not the date I set previously. Here's my code: final Calendar c = Calendar.getInstance(); final int mYear = c.get(Calendar.YEAR); final int mMonth = c.get(Calendar.MONTH); final int mDay = c.get(Calendar.DAY_OF_MONTH); DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() { // when dialog box is closed, below method will be called. public void onDateSet

How do I set the default date in a DatePickerDialog in my fragment from the host activity?

…衆ロ難τιáo~ 提交于 2019-12-13 03:38:20
问题 So I created a calendar object "c" in the Activity and set the date to February 29, 2016. I want the fragment dialog to load that date as the default date. What am I missing here? Do I need to delete the fragment calendar object 'cal'? If so, in the fragment onCreateDialog how do I reference or get() the date from the set() method in the Activity? from Activity file: @Override protected void onCreate(Bundle savedInstanceState) { ... final Calendar c = Calendar.getInstance(); c.set(Calendar

Android DatePicker in spinner mode not showing date

纵然是瞬间 提交于 2019-12-13 03:12:59
问题 I'm using DatePicker in spinner mode, and sets min and max limit. Then updates the date as max value. Date column does not have a value when the DatePickerDialog shown. When I tap/scroll up or down the values are shown. MyLayout: <DatePicker android:id="@+id/date_picker" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="@dimen/spacing_default" android:layout_marginRight="@dimen/spacing_default" android:datePickerMode="spinner" android

How can I setMaxDate() for DatePicker to one month after the current date?

半腔热情 提交于 2019-12-12 18:51:34
问题 Here's my onCreateDialog : DatePickerDialog dialog = new DatePickerDialog(this, dpickerListener, year_x, month_x, day_x); dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000); dialog.getDatePicker().setMaxDate(); As you can see, setMaxDate() is empty. I want to set the max date of the datePickerDialog to one month after the current date. Here's how I get the current date: cal2 = Calendar.getInstance(); currentDay = cal2.get(Calendar.DAY_OF_MONTH); currentMonth = cal2.get

when using datepicker in android 4.0 and above..how to avoid the calender view

 ̄綄美尐妖づ 提交于 2019-12-12 09:43:09
问题 i have done a project in android 2.2 which contains a date picker and set the properties for it according to he size of screen but when i installed it in android 4.0...the date picker view includes a calender view ....what to do to avoid the calender view along with datepicker in android 4.0...below are the images of date picker in 2.2 and 4.1 回答1: You can use yourDatepicker.setCalendarViewShown(false); This method works in Api >= 11 . 回答2: Use the code of Raval. But to run it below Android

How to Change the Datepicker style for Android

主宰稳场 提交于 2019-12-12 08:48:46
问题 I'm currently making a registration form, and one of the fields is for the users Date of Birth. I want to use datepicker, however I don't want the calendar layout as shown below: I want the layout to look something like this so that way its easier to choose the year and month without having to scroll through everything: However I do not know how to go about this, or what to put inside the styles.xml file. Any help would be greatly appreciated. 回答1: Add this to style.xml <style name="date

How to disable keyboard in TimePickerDialog android?

时光毁灭记忆、已成空白 提交于 2019-12-11 15:29:14
问题 I am using timepicker and datepicker in my app. i want to disable keyboard in both these. i am able to disable keyboard in date picker with below code. datePickerDialog.getDatePicker().setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); but not getting how to disable keyboard in timepickerdialog. i tried below popular example but still no use public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { private TimePickerDialog

Is it possible to disable certain weekdays in DatePickerDialog?

笑着哭i 提交于 2019-12-11 03:18:16
问题 I need a DatePicker for a subscription service where the customer can select view dates. But not every day is available. For example on Wednesdays is no delivery. Is it possible to disable specific week days? Or do I have to make an alert afterwards to tell him this is not possible. 回答1: in this project you will find the logic you need. DatePicker without sundays Relevant snippet: if (choosenDate.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || now.compareTo(choosenDate) < 0) { dateTextView

How to finish activity when date picker dialog on cancel button is clicked

淺唱寂寞╮ 提交于 2019-12-11 00:59:53
问题 I have implemented the date picker dialog on my activity and it works fine. When i click cancel the ate picker is dismissed so the buttons work. However i would like to capture the cancel button event and add more code to it to finish the activity but i cannot seem to be able to handle that. This is my code: public class DatePickerActivity extends Activity { static final int DATE_PICKER_ID = 1111; private int year; private int month; private int day; @Override protected void onCreate(Bundle

Error inflating class android.widget.DatePicker on android version 7.0

爷,独闯天下 提交于 2019-12-11 00:15:45
问题 I want to show popup date picker and i using this code Calendar mcurrentDate = Calendar.getInstance(); int mYear = mcurrentDate.get(Calendar.YEAR); int mMonth = mcurrentDate.get(Calendar.MONTH); int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH); DatePickerDialog mDatePicker = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) { txtDate1.setText(selectedmonth + "/" +