Disabling Spinner in android

后端 未结 4 478
太阳男子
太阳男子 2021-02-03 16:53

I\'m having problems when using android:enabled=\"false\", it\'s not disabling the component in the case it\'s a spinner

相关标签:
4条回答
  • 2021-02-03 17:21

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

    0 讨论(0)
  • 2021-02-03 17:27

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

    0 讨论(0)
  • 2021-02-03 17:34

    Disable or enable it before setting the adapter.

    yourSpinner.setEnabled(false);   
    yourSpinner.setClickable(false);  
    yourSpinner.setAdapter(typeAdapter);
    
    0 讨论(0)
  • 2021-02-03 17:39

    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);
    
    0 讨论(0)
提交回复
热议问题