0

I have an autocompletetextview where the user types, and a drop down menu populates. In this case, I am showing the user that a particular item name is used and therefore NOT available to be selected. I'd like to show the drop-down but make it NON-clickable? Is this possible?

This may not be relevant but it retrieves data from online database. I basically attach the word "Used: " + myString and that is what populates.

Edit:

Here is adapter:

            ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
                    getApplicationContext(), R.layout.dialog_dropdown_list,
                    itemList);

          etInsertAutoComplete.setAdapter(dataAdapter);
TheLettuceMaster
  • 15,594
  • 48
  • 153
  • 259
  • can you show what does the adapter for the dropdown look like? – Varun Jun 20 '13 at 23:39
  • @Varun added the requested code. – TheLettuceMaster Jun 20 '13 at 23:51
  • 1
    You can extend a `BaseAdapter` and choose which items are clickable by overriding methods.. Override `areAllItemsEnabled ()` and return false; and also override this `public boolean isEnabled (int position)` and return `true/false` as needed. – Varun Jun 21 '13 at 00:29
  • And if you are looking to make a `ListView` that has headers kind of stuff, you might want to look into `ExpandableListView`. You can see `APIDemos` for examples. – Varun Jun 21 '13 at 23:55

1 Answers1

0

I know i am too late for this answer.But this will help you out. For that you have to implement custom adapter by extend BaseAdapter. autocompleteTextview gets value using adapter.getItem(position) using the method performCompletion:

https://developer.android.com/reference/android/widget/AutoCompleteTextView.html#performCompletion()

private void performCompletion(View selectedView, int position, long id) {
    if (isPopupShowing()) {
        Object selectedItem;
        if (position < 0) {
            selectedItem = mPopup.getSelectedItem();
        } else {
           selectedItem = mAdapter.getItem(position); // It will null if we return null in getItem() method of an adapter

        }
        if (selectedItem == null) {
            return;
        }
}

dropdown will receive item click by following code,

@Override
     public Object getItem(int position)
      {
        return itemList.get(position).getName();
      }

To make it not clickable simply return null,

@Override
public Object getItem(int position) {
    return null;
}

It will show the dropdown list but item will not be clickable.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Harshal Bhatt
  • 731
  • 10
  • 25