[1] put this as a private class within whatever activity or fragment you use for your ListView
// based on http://stackoverflow.com/questions/8166497/custom-adapter-for-list-view
private class ListAdapter extends BaseAdapter {
public ListAdapter(Context context) {
super(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = LayoutInflater.from(getContext());
v = vi.inflate(R.layout.list_item, null);
// see [2] for list_item
}
// at this point you acquire whatever data you need at [position]
// from whatever database or array or whatever you have
// so if it's title and image URI,
String title = ...;
URI imageUri = ...;
TextView titleView = (TextView)v.findViewById(R.id.title);
titleView.setText(title);
ImageView thumbnailView = (ImageView)v.findViewById(R.id.image);
thumbnailView.setImageUri(imageUri);
return v;
}
[2] res/layout/list_item.xml
[3] res/drawable/card_style_background.xml
-
-