Android AutocompleteTextView using ArrayAdapter and Filter

后端 未结 3 1143
梦如初夏
梦如初夏 2020-12-29 22:04

Backgroud information

The app I am currently writing deals with places. The main method to create a place is to enter an address. Providing a convenient way to do

3条回答
  •  一个人的身影
    2020-12-29 22:46

    I think your problem is you are setting lastSuggested to suggested (via filterResults.values) and then, in the next pass, you are updating suggested --> lastSuggested will be set to the same value as suggested as Java passes variables by reference unless primitives.

    So, instead of

    if ( filterResults.count > 0) { lastSuggested = (ArrayList) filterResults.values; }

    You should try

    if ( filterResults.count > 0) {
        lastSuggested.clear();
        ArrayList
    tempList = (ArrayList
    ) filterResults.values; int i = 0; while (i < tempList.size()){ lastSuggested.add(tempList.get(i)); i += 1; } }

提交回复
热议问题