Android: Using item selected in AutoCompleteTextView to populate another field

前端 未结 2 2082
半阙折子戏
半阙折子戏 2021-02-10 01:47

I am trying to build an app where the names of employees are stored in a table. On a particular page, the user can enter the name of an employee in an autocompletetextview and s

相关标签:
2条回答
  • 2021-02-10 02:33

    You can create a custom Adapter for your AutoCompleteTextView which has all the info, say you have a class People(name, department, designation).

    Something like

    autoCompleteTextView.setAdapter(new CustomAdapter<People>(getBaseContext(),  android.R.layout.simple_list_item_1, "a list of all your people"))
    
    0 讨论(0)
  • 2021-02-10 02:52

    I found the problem.... It was because of the missing piece of code in the performFiltering method... When the constraint (or prefix) using which the list has to be filtered is null we just need to return the entire list back.... Once this was added in the else for the null check for constraint the filtering works like golden....

                ArrayList <Part_Mstr_Info> list = new ArrayList <Part_Mstr_Info>(orig);
                results.values = list;
                results.count = list.size();
    
    0 讨论(0)
提交回复
热议问题