Aditya Vyas Aditya Vyas - 4 months ago 6x
JSON Question

How to add json values in single row of autocompletetextview?

I am using this example of autocompletetextview,now i am able to get name in suggestion,the output is like



but the issue is i want to get id and name in single row,like

1 ab

2 abc


You have to append id also with name. Have a look at following code:

            protected FilterResults performFiltering(CharSequence constraint) {
                FilterResults filterResults = new FilterResults();
                JsonParse jp=new JsonParse();
                if (constraint != null) {

                    List<SuggestGetSet> new_suggestions =jp.getParseJsonWCF(constraint.toString());
                    for (int i=0;i<new_suggestions.size();i++) {
                        //  Append id and name here 
                        suggestions.add(new_suggestions.get(i).getId()+" "+new_suggestions.get(i).getName());

                    filterResults.values = suggestions;
                    filterResults.count = suggestions.size();
                return filterResults;