如何选择多个联系人并将它们传递给另一个意图android
问题描述:
我有一个活动中的每个项目前的复选框项目列表。使用可以选择多个项目,然后这些项目应该传递给另一个意图。 有人可以告诉我如何根据复选框选择标识所选项目。如何选择多个联系人并将它们传递给另一个意图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" />
答
在这种情况下使用以下布局的每个项目我假设你有保持复选框的ArrayList意味着被选中该检查或是非 - 通过这种方式选择。您将获得将哪个联系人发送给其他活动。
现在为了将联系值从一个活动传递到另一个活动,您可以使用Bundle
。
Bundle mBundle=new Bundle();
mBundle.putStringArrayList("KeyValue", ArrayList Contact name);
mIntent.putExtras(mBundle);
您可以在下面的活动中获得Bundle,如下面的代码。
Bundle mBundle=getIntent().getBundleExtra("KeyValue");
+0
万一您可以引用数据类型,可根据需要通过'Bundle'传递。 – Herry
通过这个[链接](http://*.com/questions/9450058/using-checkbox-to-filter-contacts-and-get-phone-number/10105655#10105655) – Satheesh
这个工作Satheesh!非常感谢 ! – Harish