0
我創建了一個ListActivity擴展arrayAdapter;列表中的每個元素都由2個標籤和1個複選框組成。它工作得很好,除非我取消選中其中一個列表框並向上或向下滾動,使此檢查不可用;問題是,當我取回先前未經檢查的複選框時,它被檢查...我的listActivity出了什麼問題?這是基於ArrayAdapter的類:我的ListActivity有什麼問題?
private class DescrAdapter extends ArrayAdapter<StatDescriptor>{
private LayoutInflater inflater;
private final StatDescriptor[] descriptions;
private int layoutId;
public DescrAdapter(Context context, int res,StatDescriptor[] objects) {
super(context,res , objects);
this.inflater=LayoutInflater.from(context);
this.descriptions=objects;
this.layoutId=res;
}
public View getView(final int position, View rowView, ViewGroup parent) {
rowView = (RelativeLayout) inflater.inflate(layoutId, null);
TextView textName = (TextView) rowView.findViewById(R.id.StatName);
textName.setText(descriptions[position].getName());
TextView textDescr=(TextView) rowView.findViewById(R.id.StatDescr);
textDescr.setText(descriptions[position].getDescription());
CheckBox checkEnabled=(CheckBox) rowView.findViewById(R.id.checkStat);
checkEnabled.setChecked(descriptions[position].isEnabled());
checkEnabled.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
enabledStats[sortIndexes[position]]=!enabledStats[sortIndexes[position]];
}
});
return rowView;
}
}
感謝您的幫助。
什麼意思是「當我回來時」,你是在說推backButton嗎? ,還是隻滾動? –