0

当我尝试检查自定义 listView 中某个项目的 CheckBox (其中每一行包含一个图像视图、一个文本和一个复选框)时,其他一些未选中的复选框被选中。

我的适配器是

public class MyAdapter extends BaseAdapter{
    private Activity activity;
    private String[] dataCar;
    private String[] dataImm;

    private static LayoutInflater inflater=null;
    public TitleLoader titleLoader;
    public ImageLoader imageLoader; 
    public TextLoader textLoader;

    public MyAdapter(Activity a, String[] dCar, String[] dImm) {
        activity = a;
        dataCar=dCar;
        dataImm=dImm;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        titleLoader=new TitleLoader(activity.getApplicationContext());
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return dataImm.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.elemento_lista_car, null);

        TextView car=(TextView)vi.findViewById(R.id.car);
        ImageView image=(ImageView)vi.findViewById(R.id.image);
        CheckBox cb=(CheckBox)vi.findViewById(R.id.checkBox);
        titleLoader.DisplayTitle(dataCar[position], car);
        imageLoader.DisplayImage(dataImm[position], image);

        return vi;
    }

}
4

0 回答 0