2012-05-04 29 views
0

我有一個活動中的每個項目前的複選框項目列表。使用可以選擇多個項目,然後這些項目應該傳遞給另一個意圖。 有人可以告訴我如何根據複選框選擇標識所選項目。如何選擇多個聯繫人並將它們傳遞給另一個意圖android

我在列表

<?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" /> 

+0

通過這個[鏈接](http://stackoverflow.com/questions/9450058/using-checkbox-to-filter-contacts-and-get-phone-number/10105655#10105655) – Satheesh

+0

這個工作Satheesh!非常感謝 ! – Harish

回答

0

在這種情況下使用以下佈局的每個項目我假設你有保持複選框的ArrayList意味着被選中該檢查或是非 - 通過這種方式選擇。您將獲得將哪個聯繫人發送給其他活動。

現在爲了將聯繫值從一個活動傳遞到另一個活動,您可以使用Bundle

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

您可以在下面的活動中獲得Bundle,如下面的代碼。

Bundle mBundle=getIntent().getBundleExtra("KeyValue"); 
+0

萬一您可以引用數據類型,可根據需要通過'Bundle'傳遞。 – Herry

相關問題