android 智能电视 listview 顺序错乱
2015-03-30 18:07
253 查看
最近发现listview 填充好之后总是顺序错了
为了解决这个问题参考网上的思路
解决办法
ImageView imageView = null;
TextView textView2_appname = null;
int index;
try {
index = (Integer) convertView.getTag();
} catch (Exception e) {
index =-1;
e.printStackTrace();
}
if (index != position) {
convertView = layoutInflater.inflate(R.layout.addapk_item, null);
imageView = (ImageView) convertView.findViewById(R.id.iv_icon);
textView2_appname = (TextView) convertView
.findViewById(R.id.tv_appname);
if (Applist.size() == 0) {
textView2_appname.setText("没有对应类型APP");
} else {
imageView.setBackgroundDrawable((Drawable) Applist
.get(position).get("icon"));
textView2_appname.setText((String) Applist.get(position).get(
"appname"));
convertView.setTag(position);
}
}else {
time = time+1;
}
return convertView;
}
使用settag()解决这个问题,每次去获取tag是不是和post对应,对应的话就 返回listview缓存中的view,不是的话就重新填充
欢迎大家批评指证
为了解决这个问题参考网上的思路
解决办法
ImageView imageView = null;
TextView textView2_appname = null;
int index;
try {
index = (Integer) convertView.getTag();
} catch (Exception e) {
index =-1;
e.printStackTrace();
}
if (index != position) {
convertView = layoutInflater.inflate(R.layout.addapk_item, null);
imageView = (ImageView) convertView.findViewById(R.id.iv_icon);
textView2_appname = (TextView) convertView
.findViewById(R.id.tv_appname);
if (Applist.size() == 0) {
textView2_appname.setText("没有对应类型APP");
} else {
imageView.setBackgroundDrawable((Drawable) Applist
.get(position).get("icon"));
textView2_appname.setText((String) Applist.get(position).get(
"appname"));
convertView.setTag(position);
}
}else {
time = time+1;
}
return convertView;
}
使用settag()解决这个问题,每次去获取tag是不是和post对应,对应的话就 返回listview缓存中的view,不是的话就重新填充
欢迎大家批评指证
相关文章推荐
- Android ListView Button 顺序错乱
- 基于Android智能电视的应用程序的布局
- Android智能电视应用程序开发浅谈(二)
- Android ListView滑动过程中图片显示重复错乱闪烁问题解决
- Android实战技术:ListView刷新的顺序问题
- android CTS测试之TV智能电视总结笔记
- android开发--ListView+Json+异步网络图片加载+滚动翻页的例子(图片能缓存,图片不错乱)
- Android ListView滑动过程中图片显示重复错乱闪烁问题解决
- Android ListView滑动过程中图片显示重复错乱闪烁问题解决
- Android ListView滑动过程中图片显示重复错乱闪烁问题解决
- Android ListView滑动过程中图片显示重复错乱闪烁问题解决
- Android智能电视应用程序开发浅谈(三)
- Android ListView CheckBox状态错乱
- 联想K系引领智能电视潮流,Android 4.0将成行业标配
- Android智能电视的使用特点
- Android智能电视应用程序开发浅谈(一)
- Android中ListView组件的Item拖动(Item改变顺序)
- Android实战技术:ListView刷新的顺序问题
- Android ListView滑动过程中图片显示重复错乱闪烁问题解决
- Android Listview 按钮点击状态错乱之解决