Android Spinner with different layouts for “drop down state” and “closed state”?

前端 未结 6 2086
迷失自我
迷失自我 2020-11-29 01:42

I have an Android Spinner view in my layout. I would like that spinner to show only a single text item when closed, but when the user clicks on it (i.e. opens the spinner di

6条回答
  •  生来不讨喜
    2020-11-29 01:53

    You have to create a custom Adapter class for the Spinner and overwrite the two methods getView() for the normal closed view and getDropDownView() for the drop down list view. Both methods must return a View object for a single element.

    Have a look at this tutorial it might help you getting started.

提交回复
热议问题