Disabling Spinner in android

為{幸葍}努か 提交于 2019-12-02 23:15:22
himb2001

Disable or enable it before setting the adapter.

yourSpinner.setEnabled(false);   
yourSpinner.setClickable(false);  
yourSpinner.setAdapter(typeAdapter);

It's not possible to enable/disable a Spinner in XML (yet). To do so you have to do it in code.

Here's an example:

Spinner spinner = (Spinner) findViewById(R.id.mySpinner);
spinner.setEnabled(false);
Zephyr

you can set android:clickable="false" in the xml to disable the spinner for click event.

AlbeyAmakiir

You can set this in the Java code itself, instead of in the XML, because the Spinner should implement setEnabled(boolean) from View.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!