0

I have a ListView in my Application containing custom list items with text views and a checkbox.

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:textColor="#5d5d5d"
    android:textStyle="bold" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="left"
    android:textColor="#5d5d5d"
    android:textStyle="bold" />

<CheckBox
    android:id="@+id/checkBox1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:layout_alignParentLeft="true" />

When I perform a click a onItemClickListener is called

lv.setOnItemClickListener(new OnItemClickListener() { 

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            ...
            saveListID(id);     
        }

    });

I want to perform a different Action when the CheckBox and not the item itself is clicked. But how can i get the action and the position of the item?

As adapter for the List I use the following:

BaseAdapter adapter = new SimpleAdapter(MainActivity.this, List,
            R.layout.list_item,
            new String[] { TAG_NAME, TAG_DATE }, new int[] {
                    R.id.name, R.id.date });

    setListAdapter(adapter);
f1rst
  • 25
  • 3
  • You have to implement your own adapter to achieve this. – Chandrakanth Jan 07 '15 at 15:04
  • Create custom adapter. See this http://stackoverflow.com/questions/11343773/when-scrolling-custom-listview-the-checkbox-value-changes Will totally work as per you needs. – Rohit5k2 Jan 07 '15 at 15:11

0 Answers0