Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable / disable click in spinner android?

Based on the condition i would like “to show the drop down view of a spinner or show a default value and do not show the drop down”. I used setClickable(false) in the spinner object but it didn’t work. How to implement it?

like image 793
quest Avatar asked Mar 15 '23 17:03

quest


2 Answers

Try:

((Spinner) spinner).getSelectedView().setEnabled(false);
spinner.setEnabled(false);
like image 125
cw fei Avatar answered Mar 28 '23 13:03

cw fei


Disable or enable it before setting the adapter.

spinner.setEnabled(false);   
spinner.setClickable(false);  
spinner.setAdapter(typeAdapter);
like image 36
KishuDroid Avatar answered Mar 28 '23 14:03

KishuDroid