addView(View) is not supported in AdapterView
You are trying to set it to your ListView
. That's not going to work. Try setting it to it's parent. With something like
listContacts.getParent().addView(aux);
Edit after comments
To add an item to your ListView
you need to add it to whatever list you use to populate your ListView
and call setAdapter()
on it or notifyDataSetChanged()
on your Adapter
.
You don't add items to your ListView
. You add items to your Adapter
and set the Adapter
on the ListView
.
I suggest going through this tutorial
and reading through the docs thoroughly.
ListView
Adapter
From the docs
An Adapter object acts as a bridge between an AdapterView and the underlying data for that view. The Adapter provides access to the data items. The Adapter is also responsible for making a View for each item in the data set.
Your ListView
is the AdapterView
here (it could be a Spinner
or other such things)