Hi
I have created custom listview which contain Imageview+TextView+Checkbox Now my problem is that i have to get which row's check box is checked.
Xml row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:orientation="horizontal" android:layout_width="fill_parent"
android:gravity="center_vertical" android:layout_height="60dip">
<LinearLayout android:id="@+id/LinearLayout03"
android:orientation="vertical" android:gravity="center_vertical"
android:layout_marginLeft="10dip" android:layout_height="60dip"
android:layout_width="260dip">
<TextView android:id="@+id/desc" android:layout_width="fill_parent"
android:layout_height="40dip" android:ellipsize="marquee"
android:text="Text" android:textSize="20dip" android:textStyle="bold"
android:gravity="center_vertical" android:textColor="@color/black" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Phone number"
android:id="@+id/phone_no" android:textColor="@color/black"></TextView>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent" android:gravity="center_vertical"
android:layout_height="60dip">
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/chk_number"></CheckBox>
</LinearLayout>
</LinearLayout>
and Adapter is:
class ContactList extends ArrayAdapter{
Activity context;
public ContactList(Activity context) {
super(context, R.layout.row,names);
this.context = context;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View row = inflater.inflate(R.layout.row, null);
TextView Name = (TextView) row.findViewById(R.id.desc);
TextView Number = (TextView) row.findViewById(R.id.phone_no);
Name.setText(names.get(position));
Number.setText(numbers.get(position));
CheckBox checkboxnumberScramble = (CheckBox) row.findViewWithTag(R.id.chk_number);
checkboxnumberScramble.setChecked(true);
checkboxnumberScramble.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
if (isChecked) {
setCheckboxflag(true);
}else{
setCheckboxflag(false);
}
}
});
return (row);
}
}
I get exception on onCreate of my Activity .