我有一个带有一些项目的ListView.我在ListView的每一行都有toggleButton.假设没有选择任何toggleButtons.滚动效果很好.但当我检查toogleButton,然后滚动我的listView时,当所选的toggleButton的行向上移动时,最后一个toggleButton(未选中)会自动检查.这种模式还在继续.我认为它与重用listItems的行有关.
我在下面添加了适配器类,列表项加载
我在下面添加了适配器类,列表项加载
public View getView(int position,View convertView,ViewGroup parent) { // TODO Auto-generated method stub View rowview = convertView; if (null == rowview) { rowview = inflator.inflate(R.layout.groupsettinglistitem,null); SettingsGroupListItem viewholder=new SettingsGroupListItem(); viewholder.gpname=(TextView) rowview.findViewById(R.id.textView1); viewholder.status=(ToggleButton) rowview.findViewById(R.id.ToggleButton1); viewholder.status.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Toast.makeText(v.getContext(),"click",Toast.LENGTH_SHORT); } }); rowview.setTag(viewholder); } SettingsGroupListItem holder=(SettingsGroupListItem) rowview.getTag(); holder.gpname.setText(items[position].getGpname().getText().toString()); rowview.setTag(holder); return rowview; }