0

I have a list of items with a checkbox before each item in a activity. use can select multiple items and then those items should be passed to another intent. Can one please tell me how can I identity the items selected based on the checkbox selection.

I am using below layout for each item in the list

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:padding="6dip" android:layout_height="?android:attr/listPreferredItemHeight">
<CheckBox
    android:id="@+id/result_icon"        
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_marginRight="6dip"        
    android:src="@drawable/ic_launcher"/>
<TextView
    android:id="@+id/result_name"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"        
    android:layout_toRightOf="@id/result_icon"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"        
    android:layout_alignWithParentIfMissing="true"                
    android:gravity="center_vertical"
    android:text="Title" />
<TextView  
    android:id="@+id/result_second_line"
    android:layout_width="fill_parent"
    android:layout_height="26dip"      
    android:layout_toRightOf="@id/result_icon"
    android:layout_below="@id/result_name"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"        
    android:singleLine="true"
    android:ellipsize="marquee"
    android:text="Second line" />

Harish
  • 63
  • 1
  • 2
  • 7
  • Go through this [link](http://stackoverflow.com/questions/9450058/using-checkbox-to-filter-contacts-and-get-phone-number/10105655#10105655) – Satheeshkumar May 04 '12 at 12:35

1 Answers1

0

In this case i assume that you have maintain a ArrayList for Check Box means which check box is selected or which is non-selected .by this way you will get which contact to send to another activity.

Now for passing contact value from one activity to another you can use Bundle.

Bundle mBundle=new Bundle();
        mBundle.putStringArrayList("KeyValue", ArrayList Contact name);
        mIntent.putExtras(mBundle);

you can get Bundle in next activity like below code.

Bundle mBundle=getIntent().getBundleExtra("KeyValue");
Herry
  • 7,037
  • 7
  • 50
  • 80