How do I make a Spinner's “disabled” state look disabled?

后端 未结 13 1515
傲寒
傲寒 2020-12-09 03:00

When I disable my Spinner it looks almost exactly like it did prior to being disabled, i.e.

Before

13条回答
  •  执笔经年
    2020-12-09 03:05

    I had a similar problem, except getChildView returned null for me, so the excepted solution did not work. I believe this was caused because I set the adapter in XML, and this ignored the "clickable" and "enabled" attributes.

    This was my XML:

    
    

    The solution for me was to remove the "enabled" and "clickable" attributes and put the following code in my "onCreate"

    spinner.setEnabled(false);
    

    Hope it helps someone!

提交回复
热议问题