Text color of a closed spinner

前端 未结 6 1345
孤独总比滥情好
孤独总比滥情好 2020-12-01 16:03

I understand that the closed spinner is actually a View, I think. But I am guessing it has a TextView there somewhere to show the text. How do I

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 16:23

    I understand that the closed spinner is actually a View, I think.

    Yes. Specifically, it is whatever you told your SpinnerAdapter to create.

    But I am guessing it has a TextView there somewhere to show the text.

    That would depend on what you told your SpinnerAdapter to create.

    How do I get access to that TextView so I can change the textcolor?

    Ideally, you don't -- you give it the right color in the first place, via whatever you told your SpinnerAdapter to create. If the color varies, override getView() in your SpinnerAdapter and change the color at that point.

    In a pinch, you can try calling getSelectedView() to get the current View being shown by the closed Spinner, but whatever change you make here may be eliminated on the user's next selection, and the alternate color may return later on if the earlier View gets recycled.

提交回复
热议问题