android-datepicker

Impossible to make my DatePickerDialog use a spinner style programmatically

☆樱花仙子☆ 提交于 2019-11-30 09:16:52
I'm using a DialogFragment to open a DatePickerDialog public class DatePickerFragment extends DialogFragment{ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it DatePickerDialog DatePickerDialog = new DatePickerDialog(getActivity(), (ProfileCreationActivity)getActivity(), year, month, day); return DatePickerDialog

Open a DatePickerDialog on Click of EditText takes two clicks

爷,独闯天下 提交于 2019-11-30 08:25:23
I want to open a Calendar on the click of Edit text. After that I want to set the date which the user selects from the Calendar in the edit text. Problem is that, only when I click on the EditText for the second time then the calendar open. Please help me to resolve the issue( why calendar don't open for the first time ). EditText XML code <EditText android:id="@+id/dateofBirth" android:layout_width="290dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginTop="10dp" android:maxLines="1" android:hint="dd/mm/yyyy" /> Activity Code public void

Setting time and date to date picker and time picker in android

丶灬走出姿态 提交于 2019-11-30 07:45:07
问题 I am using a date picker and time picker in my application. I want to set the date and time when the page loads. Is this possible? How so? 回答1: I solved a similar problem of mine as follows Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); int hour = cal.get(Calendar.HOUR_OF_DAY); int min = cal.get(Calendar.MINUTE); datePicker.updateDate(year, month, day); timePicker.setCurrentHour(hour);

DatePicker crash in samsung with android 5.0

柔情痞子 提交于 2019-11-30 06:03:45
I am having trouble with creating a datepicker in samsung note 2 device with lollipop 5.0. The exception is: java.util.IllegalFormatConversionException: %d can not format java.lang.String arguments at java.util.Formatter.badArgumentType(Formatter.java:1489) at java.util.Formatter.transformFromInteger(Formatter.java:1689) at java.util.Formatter.transform(Formatter.java:1461) at java.util.Formatter.doFormat(Formatter.java:1081) at java.util.Formatter.format(Formatter.java:1042) at java.util.Formatter.format(Formatter.java:1011) at java.lang.String.format(String.java:1803) at android.content.res

Android: DatePicker and DatePicker Dialog

房东的猫 提交于 2019-11-29 23:21:27
I have this code here on the options menu Dialog dialog = new Dialog(ScheduleActivity.this); dialog.setTitle("Add Event"); dialog.setContentView(R.layout.add_even_on); Button datePicker = (Button) dialog.findViewById(R.id.datePicker); final DialogFragment dateFrag = new MyDatePicker(); datePicker.setOnClickListener(new OnClickListener() { public void onClick(View v) { dateFrag.show(getSupportFragmentManager(), "datePicker"); } }); dialog.show(); when, say "Add Event" on the option menu is clicked, a Dialog appears, with a button that shows a DatePickerDialog and beside it is a TextView that

Date Picker with max and minimum date in onDateChanged() in Android 1.5?

陌路散爱 提交于 2019-11-29 23:04:39
问题 I am working on DatePicker in android 1.5. I am trying to set Maximum and minimum date.Minimum date should be the current date and maximum date should be the date which I will supply from string as maxYear, maxMonth, maxDay.(Suppose Todays date=30/12/2011, but it selects 29/12/2011) Everything working fine with minimum date.As it shows current date only.But on selection using minus button on picker, it selects a date less than today's date. While in case of maximum date selection it selects

Set MinDate and MaxDate in DatePIcker

白昼怎懂夜的黑 提交于 2019-11-29 21:54:16
问题 Creating app in which i am showing DatePicker.Now i want to set MinDate of DatePicker is previous two years and max date future two years only.Selection should be base on current date.Suppose current Date is 23/11/2016 so datepicker should show date till 23/11/2014 in DatePicker all the date should be disabled before the 23/11/2014.And when we click on Datepicker cursor should be on current date.Created DtaePicker private void showDateDailog() { final DatePickerDialog datePickerDialog = new

Android DatePicker : Disabling the PREVIOUS dates based on the CURRENT date

*爱你&永不变心* 提交于 2019-11-29 15:34:24
I have a DatePicker in my app which is set in this way : Layout : <TextView android:id="@+id/traveltext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1.11" android:text="Date Of Travel" android:textStyle="bold" /> <EditText android:id="@+id/txtDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" > </EditText> <Button android:id="@+id/btnCalendar" android:layout_width="30dp" android:layout_height="42dp" android:layout_marginRight="50dp" android:background="@drawable/date" > </Button> <

Open a DatePickerDialog on Click of EditText takes two clicks

本小妞迷上赌 提交于 2019-11-29 11:14:57
问题 I want to open a Calendar on the click of Edit text. After that I want to set the date which the user selects from the Calendar in the edit text. Problem is that, only when I click on the EditText for the second time then the calendar open. Please help me to resolve the issue( why calendar don't open for the first time ). EditText XML code <EditText android:id="@+id/dateofBirth" android:layout_width="290dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout

How to change textsize in datepicker?

陌路散爱 提交于 2019-11-29 06:13:24
The default textsize in datepicker is too big for my app. I've seen a way suggested to change it here , but fishing around for the textviews nested inside the datepicker class seems clunky and error prone. Is there a better/cleaner way to do it? The easiest way to change the font size of datepicker/timepicker/numberpicker is customizing the theme. In styles file, set the default font size in the following way. <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="android:textSize">22sp</item> </style> Setting a theme to DatePicker