我只想在列表视图中添加一个复选框,我正在研究,只是发现如何在所有行中使用复选框,但我只希望它在一行中。
提前致谢
- 编辑 -
谢谢@Gaurav,我正在研究,我可以做到,但是现在当我尝试单击带有复选框的项目时,它没有被单击
基础适配器
public View getView(int arg0, View arg1, ViewGroup arg2) {
View v = arg1;
if(arg1 == null){
LayoutInflater inf = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inf.inflate(R.layout.row, null);
}
Articulos art = items.get(arg0);
TextView nombre = (TextView) v.findViewById(R.id.tvNombreRow);
nombre.setText(art.getNombre());
CheckBox check = (CheckBox) v.findViewById(R.id.chkCuadroRow);
check.setChecked(art.getEstado());
if(art.getVisible()){
check.setVisibility(View.VISIBLE);
}else{
check.setVisibility(View.INVISIBLE);
}
return v;
}
主要的
ArrayList<Articulos> arrayList = new ArrayList<Articulos>();
Articulos articulos;
articulos = new Articulos("Color de fondo",false,false);
arrayList.add(articulos);
articulos = new Articulos("Vencimiento de bonos",false,false);
arrayList.add(articulos);
articulos = new Articulos("Comparte esta aplicacion",false,false);
arrayList.add(articulos);
articulos = new Articulos("Visualizador de tiempo",true,true);
arrayList.add(articulos);
articulos = new Articulos("Configuración",false,false);
arrayList.add(articulos);
articulos = new Articulos("Tutorial",false,false);
arrayList.add(articulos);
articulos = new Articulos("Acerca de",false,false);
arrayList.add(articulos);
articulos = new Articulos("Salir",false,false);
arrayList.add(articulos);
BaseAdapterCustom adapter = new BaseAdapterCustom(this, arrayList);
lstConfiguracion.setAdapter(adapter);
可能是什么问题呢?