Show user dialog when clicking on counter

I currently have a counter in dialog mode.

  <Spinner android:spinnerMode="dialog" android:id="@+id/genderSpinner" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:entries="@array/gender_array" android:prompt="@string/gender_prompt" /> 

He will show something like this

enter image description here

However, sometimes I like to control the type of dialogue. For example, I would like to show a dialog with a date when the click is clicked.

Note. Google Calendar has these controls.

enter image description here

Can I find out how I can achieve this?

+3
android
source share
2 answers

Do not use Spinner, but use TextView and set a click listener for it.

To make TextView look like a spinner, here is a technique

  <TextView android:id="@+id/date" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.72" android:text="Aug 20, 2012" style="@android:style/Widget.Holo.Light.Spinner" /> 

or

  <TextView android:id="@+id/date" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.72" android:text="Aug 20, 2012" style="@android:style/Widget.Holo.Spinner" /> 
+21
source share

I think that you will have problems working with Spinner. Spinner's concept is that it expects to show a list of items to the user to choose from.

Instead of Spinner, I think you should use a button that displays a user dialog containing a DatePicker. You can even connect it correctly to show the selected date as text on the button, if you want.

+1
source share

All Articles