Android ListView 一个项目中的多个图像

标签 android image listview

如何实现以下功能:ListView 的每个项目可能包含多个图像,图像的数量可能会有所不同。

例如 Example of such listView

最佳答案

覆盖 ListView 的自定义适配器中的 getView 方法。 根据图像的数量动态添加它们。

类似于下面的代码

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;
}

关于Android ListView 一个项目中的多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27546280/

相关文章:

android - 在后退按钮上 "IllegalStateException: Can not perform this action after onSaveInstanceState"

java - 从定义位置的字符串变量获取引用

python - 使用opencv捕获单张图片

java - 使 ListView 占满整个屏幕

ListView设置虚拟行高

android - 获取 ListView 可绘制对象并手动应用它

android - 如何停止正在运行的服务?

android - 如何使用 Firebase 推送通知打开 fragment ?

node.js - Heroku 找不到这个特定的图像路径。为什么?

c# 内存不足异常与 System.Drawing.Image