listview上下滑动时数据紊乱,求救 如图:1、如果listview中items超过一屏;2、点击第一个checkbox,该checkbox选中,然后滑动listview到最后一条数据;3、再返回到第一条数据时,选中的checkbox未选中。而是其他某一个checkbox选中; 求大侠。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 自己顶下: 注意是listview中数据超过1屏的时候 遇到过这样的问题,scroll的时候乱七八糟的。当时好像替换掉checkbox了。不用那控件的。大概思路是 每一个item对应一个bean,每个bean有check这个属性check属性有为true/false的值.check选项为true时一个drawable.false时另一个drawable. 组件重用问题。首先弄个选中商品的List,勾选时把商品id什么的add进去。在adapter的getView方法里加个判断。if(list.contains(id)){ checkBox.setChecked(true);} else { checkBox.setChecked(false);} 参考 这个 定义一个布尔数组专门对应每一个checkbox默认都设为false,每次点击的时候http://blog.csdn.net/gyflyx/article/details/6567916 public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub Log.e("method", "getView"); final int selectID = position; boolean bool; if(listItems.get(position).get("ck") == "0"){ bool = false; }else{ bool = true; } .........bHolder.buttonClose.setOnClickListener(new lvButtonListener(position)); } return convertView; } class lvButtonListener implements OnClickListener { private int position; lvButtonListener(int pos) { position = pos; } @Override if(v.getId() == listItemView.check.getId()){ hasChecked[pos] = !hasChecked[pos]; if(hasChecked[pos]){ //listItems.get(pos).put("info", "FUCk"); listItems.get(pos).put("ck", "1"); }else{ //listItems.get(pos).put("info", "YOU"); listItems.get(pos).put("ck", "0"); } notifyDataSetChanged(); } android消息推送(使用xmpp协议)的一些问题 求大神答疑,谢谢 如何在模拟器system/app中安装自己的apk android启动失败......打印launcher超时 求助一GridView问题 RadioGroup传值取值? windows 2003系统 怎么配置android开发环境 怎样将得到的数据添加到通知栏中 有用过友推分享组件的嘛?遇到了技术问题 防止访问url重定向时启动浏览器的shouldOverrideUrlLoading()方法无效? 其他平台的java代码如何移植到android 按官网方法下载下来的android源码包怎么添加Ethernet?
check属性有为true/false的值.
check选项为true时一个drawable.false时另一个drawable.
首先弄个选中商品的List,勾选时把商品id什么的add进去。
在adapter的getView方法里加个判断。
if(list.contains(id)){
checkBox.setChecked(true);
} else {
checkBox.setChecked(false);
}
http://blog.csdn.net/gyflyx/article/details/6567916
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Log.e("method", "getView");
final int selectID = position;
boolean bool;
if(listItems.get(position).get("ck") == "0"){
bool = false;
}else{
bool = true;
}
.........
bHolder.buttonClose.setOnClickListener(new lvButtonListener(position));
}
return convertView;
}
class lvButtonListener implements OnClickListener {
private int position;
lvButtonListener(int pos) {
position = pos;
}
@Override
if(v.getId() == listItemView.check.getId()){
hasChecked[pos] = !hasChecked[pos];
if(hasChecked[pos]){
//listItems.get(pos).put("info", "FUCk");
listItems.get(pos).put("ck", "1");
}else{
//listItems.get(pos).put("info", "YOU");
listItems.get(pos).put("ck", "0");
}
notifyDataSetChanged();
}