Adding attributes in ListView

DavidEFC

New Member
I have a problem with my ListView. I want it to contain different values from my object.My object Item has 4 attributes:\[code\]String name;int number;int price;boolean check;\[/code\]This is my code:\[code\]ArrayList<Item> list = new ArrayList<Item>();list.add(new Item("hej", 1, 1, false));list.add(new Item("farvel", 2, 2, true));setListAdapter(new ArrayAdapter<Item>(this, R.layout.list_item, R.id.tv, list));ListView lv = getListView();lv.setTextFilterEnabled(true);\[/code\]Now i want the true/false to be linked to my checkbox in this XML:\[code\]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" ><CheckBox android:id="@+id/cb" android:layout_width="wrap_content" android:layout_height="wrap_content" /><TextView android:id="@+id/tv" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" android:textSize="16sp" ></TextView></LinearLayout>\[/code\]I would really like your help!!
 
Back
Top