Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable an autocomplete item?

I want all the 'not available' item to be disabled i.e. the dropdown should stay intact when I click them.

enter image description here

I tried setting the convertView clickable false, but that didn't help.

like image 551
luckyNinja Avatar asked Oct 19 '25 08:10

luckyNinja


1 Answers

in your adapter's `getView()' method check

if (text.equals("not available")) {
    convertView.setEnabled(false);
} else {
    convertView.setEnabled(true);
}

override in your adapter

public boolean areAllItemsEnabled() {
    return false;
}

public boolean isEnabled(int position) {
    // return false if position == position you want to disable
}

check it here Android ListView child View setEnabled() and setClickable() do nothing

like image 70
vs.thaakur Avatar answered Oct 21 '25 22:10

vs.thaakur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!