2012-05-04 2 views
0

활동의 각 항목 앞에 확인란이있는 항목 목록이 있습니다. use는 여러 항목을 선택할 수 있으며 그 항목은 다른 의도로 전달되어야합니다. 확인란을 선택하여 선택한 항목을 어떻게 확인할 수 있습니까? 나는이 경우 목록여러 연락처를 선택하여 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 mBundle=getIntent().getBundleExtra("KeyValue"); 
+0

을 참조하십시오. 필요한 경우 Bundle로 전달할 수있는 데이터 유형을 참조 할 수 있습니다. – Herry

관련 문제