As said above you have to use an Adapter I would create your own and add this to you ListView. This is roughly how you would do it, code bit rough as type it straigh into text editor here:
public class ContactListAdapter extends ListAdapter<String> {
private final List contacts;
//Call to super to set up the adapter
public ContactListAdapter(Context context, List<Contact> contacts) {
super(context, R.layout.rowlayout, values);
this.contacts = contacts;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//Get your View
View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
//create the emelements you want to add to list
TextView textView = (TextView) rowView.findViewById(R.id.label);
textView.setText(contacts.get(position).getId())
return rowView
}
}
Then add this adapter to your ListView and Initialize it
Hope this helps you
1
solved android view data from database to list view [closed]