2012-05-04 4 views
0

私は、アクティビティの各項目の前にチェックボックス付きの項目のリストを持っています。複数の項目を選択してから別の目的に渡す必要があります。 チェックボックスの選択に基づいて選択したアイテムをどのように識別することができますか教えてください。この場合複数の連絡先を選択してアンドロイドの別のインテントに渡す方法

私は、リスト内の各項目のレイアウトの下に使用しています

<?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 mBundle=getIntent().getBundleExtra("KeyValue"); 
+0

が必要な場合は、 'Bundle'で渡すことができるデータ型を参照することができます。 – Herry

関連する問題