4

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.

mmBs
  • 8,421
  • 6
  • 38
  • 46
luckyNinja
  • 203
  • 1
  • 10

1 Answers1

8

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

vs.thaakur
  • 619
  • 3
  • 13
  • setEnabled() does not enable or disable list items when called on the list item's view. – Mark Buikema Mar 03 '14 at 09:31
  • I've tries the first block of code, then second block of code, but it didn't appear to me that they should work if put together. Thanks! – RexSplode Feb 07 '17 at 12:56