我正在使用一个listview st,每行都有一个imageview和一个flowlayout,我扩展了baseadapter并向它发送了一个hashmap的arraylisy,每个都有图像路径和一个单词列表我的问题是每次我向上滚动一个条目“叶子” 屏幕然后向下,条目“返回”到屏幕 条目流程布局中被回收的单词正在被复制(这意味着如果键上磁盘旁边的单词是“dok”,那么在我向下滚动之后然后再次向上流动布局中的单词现在是“dok dok”)......我不知道为什么...... =(
我从这里把flowlayout +气泡带到了它 - http://www.superliminal.com/sources/FlowLayout.java.html http://nishantvnair.wordpress.com/2010/09/28/android-create-bubble-喜欢脸书/
和一个解码异步任务,将图像从@MCeley 的答案加载到列表中 - Large ListView contains images in Android
那是我的 getView 代码-
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = null;
FlowLayout flowLayout = null;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.list_item, null);
imageView = (ImageView) convertView.findViewById(R.id.list_image);
flowLayout = (FlowLayout) convertView.findViewById(R.id.flow_tags);
} else {
imageView = (ImageView) convertView.findViewById(R.id.list_image);
flowLayout = (FlowLayout) convertView.findViewById(R.id.flow_tags);
DecodeTask task = (DecodeTask) imageView.getTag(R.id.list_image);
if (task != null) {
task.cancel(true);
}
}
HashMap<String, List<String>> photos = new HashMap<String, List<String>>();
photos = data.get(position);
imageView.setImageBitmap(null);
DecodeTask task = new DecodeTask(imageView);
task.execute(photos.get(DatabaseHandler.KEY_PATH).get(0));
imageView.setTag(R.id.list_image, task);
ArrayList<String> subjects = new ArrayList<String>();
int size = photos.get(DatabaseHandler.KEY_TAGS).size();
for (int i = 0; i < size; i++) {
String name = String.format("name - %s ",
photos.get(DatabaseHandler.KEY_TAGS).get(i));
Bubble.getBubble(name, flowLayout, subjects, activity,
photos.get(DatabaseHandler.KEY_PATH).get(0), false, false);
}
return convertView;
}
TNX提前..!