I wanted to use AutoCompleteTextView in my android application.I know how to use it with simple array of Strings, but I wanted AutoCompleteTextView to use list of Objects t
if you are wanna add the data in String[] arr=new String[100]; then its wrong. You can do the same work as in form of ArrayList but remember you will never put here a Getter/Setter class. Just simply declare it. See this example.
Declare in main partition:
ArrayListarr=new ArrayList<>();
and then initilize it in this way:
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject1 = (JSONObject) jsonArray.get(i);
String imei = jsonObject1.getString("imei");
String name = jsonObject1.getString("name");
String my_pic = jsonObject1.getString("my_pic");
String email = jsonObject1.getString("email");
arr.add(name);
}
adapter= new ArrayAdapter<>
(this, android.R.layout.select_dialog_item, arr);
autoCompleteText.setThreshold(1);//will start working from first character
autoCompleteText.setAdapter(adapter);//setting the adapter data into the AutoCompleteTextView
autoCompleteText.setTextColor(Color.RED);
}
I hope this will work for you....