Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android spinner with date picker, like Google Calendar app

I'm trying to get a text box that looks like a spinner to activate a date picker dialog. This is done in both the Google Calendar app and the Contacts app (for birthdate) on ICS. Do I need to use a spinner, and if so how do I change it's input view to be a date picker? Or if not, how do I get a text view to have the little triangle that usually indicates a spinner?

like image 865
Dash Avatar asked Feb 23 '12 03:02

Dash


People also ask

Is date picker dialog class available in android?

Android Date Picker allows you to select the date consisting of day, month and year in your custom user interface. For this functionality android provides DatePicker and DatePickerDialog components.

Does android have Google Calendar?

Get Google Calendar On your Android phone or tablet, visit the Google Calendar page on Google Play. Tap Install. Open the app and sign in with your Google Account.

How do I customize Google Calendar widget android?

Search for the Google Calendar app and tap it. To customize your widget size, swipe left. Tap Add widget. In the top right, tap Done.

How do I get the calendar to pop up on my android?

Android Show DatePicker on EditText Click Example Following is the example of open or popup datepicker dialog when we click on EditText control and get the selected date value on Button click in the android application. Create a new android application using android studio and give names as DatePickerExample.


1 Answers

Twaddington's comment on his answer is actually the right approach. What you need is to create a text view and apply the style

style="@android:style/Widget.DeviceDefault.Light.Spinner" 

Then you can create a click listener on the text view and use it to open a DatePickerDialog. That can be accomplished as shown here: https://stackoverflow.com/a/8127571/332738 (If you follow the example, remember to add a default constructor to DatePickerDialogFragment so that your app does not crash on rotate)

like image 179
codinguser Avatar answered Sep 20 '22 02:09

codinguser