Reputation: 115
How can I implement the following feature: each item of a ListView
may contain several Images and the number of Images may vary.
for example Example of such listView
Upvotes: 1
Views: 1997
Reputation: 1601
It's simple! 1.Create your custom row layout 2.Add imageviews to your row programmatically inside adapter getView method
Upvotes: 0
Reputation: 9408
override the getView
method in your custom adapter for the listview.
Depending on the number of images add them dynamically.
something similar to the below code
public View getView (int position, View convertView, ViewGroup parent){
if( convertView == null ){
convertView = inflater.inflate(R.layout.my_list_item, parent, false);
}
//images is a array of bitmap here
for(int i =0;i<images.length;i++){
ImageView img = new ImageView(getContext());
img.setImageBitmap(images[i]);
convertView.add(img);
}
return convertView;
}
Upvotes: 3
Reputation: 111
You should use a custom adapter for that. You can search for List view custom adapter and there are tons of blog about it. Like this.
Upvotes: 1