I've a SQL Database with only one table for my checkbox : name(string) and value(boolean). At this time, I show a list of checkbox for test, but it's not from my db.
public class Model{
String name;
int value; /* 0 -> checkbox disable, 1 -> checkbox enable */
Model(String name, int value){
this.name = name;
this.value = value;
}
public String getName(){
return this.name;
}
public int getValue(){
return this.value;
}
}
// MainActivity
ListView lv;
Model[] modelItems;
lv = (ListView) findViewById(R.id.listView1);
modelItems = new Model[5];
modelItems[0] = new Model("pizza", 0);
modelItems[1] = new Model("burger", 1);
modelItems[2] = new Model("olives", 1);
modelItems[3] = new Model("orange", 0);
modelItems[4] = new Model("tomato", 1);
//Custom Adapter is a Java Class for Show ListView with Checkbox
CustomAdapter adapter = new CustomAdapter(this, modelItems);
lv.setAdapter(adapter);
Aucun commentaire:
Enregistrer un commentaire