Hi, im trying to create a listview from a selection of a AutoCompleteTextView
here's my code
final AutoCompleteTextView editText = findViewById(R.id.actv);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, names);
editText.setAdapter(adapter);
editText.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// select ACTV (AutoCompleteTextView)
String authorPicked = parent.getItemAtPosition(position).toString();
final List<News> escritor = articlesProvider.getArticlesByAuthorName(authorPic ked);
Toast toast = Toast.makeText(getApplicationContext(), authorPicked, Toast.LENGTH_SHORT);
toast.show();
ArrayList<String> articulos = new ArrayList<>();
for(Article author : escritor) {
frases.add(author.getArticle());
}
ListView myList;
myList = findViewById(R.id.ListView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, articulos);
myList.setAdapter(adapter);
}
});
but with this i don't get results if i print the value of
Log.d("Valor: ","Contiene " + escritor);
i get [] as result