MultiAutoCompleteTextView doesn't show results

China☆狼群 提交于 2019-12-12 13:59:11

问题


I have this code on my activity:

ParseQuery<ParseUser> query = ParseUser.getQuery();
query.findInBackground(new FindCallback<ParseUser>() {
    public void done(List<ParseUser> userList, ParseException e) {
        if (e == null) {
            Log.d("score", "Retrieved " + userList.size() + " scores");
            friends = new ArrayList<String>();
            for (int i = 0; i < userList.size(); i++) {
                friends.add(userList.get(i).getUsername().toString());
            }
            aAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_dropdown_item_1line, friends);
            friendChooser.setInputType(InputType.TYPE_CLASS_TEXT);
            friendChooser.setAdapter(aAdapter);
        } else {
            Log.d("score", "Error: " + e.getMessage());             
        }
    }
});

aAdapter is an ArrayAdapter. 
friendChooser is a MultiAutoCompleteTextView.  
friends is a List.  
userList is a List.

I'm trying to get an ArrayAdapter<String> of my Parse.com user's names and apply it on the MultiAutoCompleteTextView, The problem is that I don't get any results on the MultiAutoCompleteTextView. How can I solve this problem?


回答1:


I don't have much experience with MultiAutoCompleteTextViews, but according to this tutorial you need to add this lines before setting the adapter:

friendChooser.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
friendChooser.setInputType(InputType.TYPE_CLASS_TEXT);
friendChooser.setThreshold(1);

and then call:

friendChooser.setAdapter(aAdapter);

It worked for me



来源:https://stackoverflow.com/questions/32270983/multiautocompletetextview-doesnt-show-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!