转载自:http://www.jb51.net/article/106379.htm
首先需要在AndroidManifest.xml文件中添加权限:
activity_main.xml布局:
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.android_25.MainActivity">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lv_lxr"
>
activity_xs.xml布局:
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_xs"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.android_25.XsActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_name"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_telephone"
/>
MainActivity类:
private ListView lv_lxr;
private Button b_name;
private ContentResolver cr;
private List
第二种:通过Butten按钮跳转到系统的手机联系人界面,单个获取手机联系人信息,展示在ListView中
activity_contacts.xml布局:
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.android_25.ContactsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="跳转到联系人页面"
android:id="@+id/b_tzcontacts"
/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/lv_contacts"
>
ContactsActivity类:
private Button b_tzcontacts;
private String phoneName;
private String phoneNumber;
private List