Show custom dialog when spinner is being clicked

前端 未结 2 1642
小蘑菇
小蘑菇 2021-01-01 05:44

Currently, I have the spinner in dialog mode.

        

        
相关标签:
2条回答
  • 2021-01-01 06:34

    Do not use Spinner, but using TextView, and install a click listener to it.

    In order to turn TextView looks like Spinner, here is the 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" />
    
    0 讨论(0)
  • 2021-01-01 06:44

    I think you are going to have trouble making that work with a Spinner. The concept of a Spinner is such that it is expecting to show a list of items for the user to choose from.

    Instead of a Spinner I think you should use a Button that pops up a custom dialog containing a the DatePicker. You could even wire it up correctly to show the selected date as the Text on the Button if you wanted to.

    0 讨论(0)
提交回复
热议问题