android-datepicker

How to make a DatePicker with DialogFragment and FragmentManager?

给你一囗甜甜゛ 提交于 2019-12-07 10:58:53
问题 So I have been at this for a while, and I cannot seem to figure it out. I am fairly new at Android development, so bear with me please. I wasn't too familiar with creating a Datepicker and I learned to do it the deprecated way just to get the hang of it. Used this tutorial to get me up to speed: http://developer.android.com/resources/tutorials/views/hello-datepicker.html But now I need to change it, mainly to not use deprecated code, so I looked all around, and I found 2 tutorials, mainly

DatePickerDialog OK button not getting the selected date

不羁的心 提交于 2019-12-07 10:01:12
问题 I have a simple DatePickerDialog that opens when an EditText is opened. After choosing a date and pressing OK, it should be displayed at the same EditText . It works fine if I only use the default dialog where it creates only one button - OK. I added a Cancel button, the problem is that it only gets the current date. Here's my code: private void showDatePicker(String birthdayStr) { // TODO Auto-generated method stub final Calendar c = Calendar.getInstance(); if (birthdayStr.equals("")) {

Initialize date in android datepicker to a specific date, that is not the current date.

北城余情 提交于 2019-12-06 22:02:36
问题 In my app I have a date saved in a remote database that I want the date picker to be set to. I've researched and only found examples of setting the datepicker today's date via Calender java util. Example: final Calendar c = Calendar.getInstance(); year = c.get(Calendar.YEAR); month = c.get(Calendar.MONTH); day = c.get(Calendar.DAY_OF_MONTH); How can I use the Calendar to display my date from the database and not today's date? Do you have any suggestions or examples I can follow? Update: After

DatePickerDialog displays with two borders

霸气de小男生 提交于 2019-12-06 21:52:07
问题 I have a question about DatePickerDialog displaying. I want to create date picker dialog with "HoloDialog" theme like this: DatePickerDialog dpd = new DatePickerDialog(this, android.R.style.Theme_Holo_Dialog, reservationDate, 2014, 1, 1); Then I will see this result: As you can see, dialog is displayed with "two borders" around. I want to create the same dialog as displayed here, but with one border around. Is it possible? 回答1: Assuming I understand your question correctly, I think I found a

Change DatePickerDialog's button texts

假如想象 提交于 2019-12-06 16:50:56
问题 I'm having some trouble changing the text of the buttons of the dialog. I tried to use: setButton(int whichButton, CharSequence text, DialogInterface.OnClickListener listener) and setButton(int whichButton, CharSequence text, Message msg) But I could not figure out what to put as the third parameter. I could pass a new OnClickListener , but I would like to use the callback DatePickerDialog.OnDateSetListener . I guess when I set a new Listener to the Button the DateSetListener won't ne called

Date Picker with cancel option in android

烂漫一生 提交于 2019-12-06 16:46:34
问题 Is it possible to have a date/time picker that has a Cancel/Set options in place of a single Set command. My usecase is that when i click on the date picker and the field is not mandatory, i might want to clear the selected value. My code looks something like this : private DatePickerDialog datePicker = null; datePicker = new DatePickerDialog(getContext(), new DateSetListener(), year, monthOfYear, dayOfMonth); 回答1: I would use a simple Dialog and within it include a DateTimePicker and the SET

how to convert date and time to 12 hour format

我的梦境 提交于 2019-12-06 09:18:59
问题 hello i have a date and time string in 24 hour format but i want it in 12 hour how i can do this my string is String date_st="12 Nov, 2014 23:13" i am doing this SimpleDateFormat dateformat = new SimpleDateFormat("dd' 'MMM,' 'yyyy HH:mm aa"); but its not converting according to my need it shows 23:13 PM i want to show in following format String con_date= "12 Nov, 2014 11:13 PM" how i can do this? 回答1: You need two formats: one to parse, and one to format. You need to parse from String to Date

How to set the value of the datePicker in to EditText?

一个人想着一个人 提交于 2019-12-06 05:36:41
My XMl Layout is as like below: <RelativeLayout android:id="@+id/dateSelectionLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:visibility="visible"> <EditText android:layout_height="wrap_content" android:layout_width="fill_parent" android:singleLine="true" android:id="@+id/dateSelectionEditText" android:gravity="center" android:textColor="#000000" android:textSize="14sp" android:cursorVisible="false" android:focusable="false" android:hint="tax code" android:layout_weight="1"/> <DatePicker android:id="@+id/datePicker" android

white background for date picker dialog shadow

感情迁移 提交于 2019-12-05 22:34:48
I add datepicker to my application but my problem the shadow for the dialog have white background , use Android 21 for compile . please help me to remove white background ... You have a "bug" in your themes.xml or styles.xml material design support library is not working properly with dialogs. So remove the specific dialog code or separate it in different versions. Trying to explain a little bit further. Generally when we extend the original application theme we have an themes.xml and/or styles.xml files under the values folder. In there code you will find something like these: Application

Max Date on an Android DatePickerDialog

感情迁移 提交于 2019-12-05 18:32:59
I need to set a max year on the DatePickerDialog that I am using but I am unable to find any mechanism of doing that. The documentation mentions getDatePicker () as a public method of the DatePickerDialog. So, I thought, perhaps, that can be used to get the DatePicker and then I could set the max date but I get "Method undefined" error when I try to get the DatePicker. This is how I am trying to get the DatePicker inside my onCreateDialog. DatePickerDialog d = new DatePickerDialog(this, dep_dateListener, mYear, mMonth, mDay); DatePicker dp = d.getDatePicker(); dp.setMaxDate(maxDate); return d;