如何在android中创建联系人

时间:2013-03-06 05:29:18

标签: android android-layout

我的要求是我要创建一个带图像的联系人,而在联系人图像旁边我想显示联系人姓名。

以下是我的代码:这里我也可以创建联系人,但我无法获得准确的输出。

代码:

<LinearLayout 

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

<QuickContactBadge

    android:id="@+id/quickContactBadge1"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content" />

<TextView

    android:id="@+id/checkedTextView1"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:text="CheckedTextView" />

 </LinearLayout>

我的出局:

enter image description here

要求输出:

enter image description here

请有人建议我。

感谢。

1 个答案:

答案 0 :(得分:0)

快速联系徽章需要提供一些数据。如果您尚未应用任何数据,则会获得圆形头+微笑图像。你应该得到一个Uri并将其分配给徽章。

以下是Shane Conder&amp; amp;劳伦·达西:http://mobile.tutsplus.com/tutorials/android/android-sdk_contact-badge/

以下是教程中的代码段,展示了如何填充徽章:

Uri contactUri = data.getData();  
        FrameLayout badgeLargeHolder = (FrameLayout) findViewById(R.id.badge_holder_large);  
        QuickContactBadge badgeLarge = new QuickContactBadge(this);  
        badgeLarge.assignContactUri(contactUri);  
        badgeLarge.setMode(ContactsContract.QuickContact.MODE_LARGE);  
        badgeLarge.setImageResource(R.drawable.droid_small);  
        badgeLargeHolder.addView(badgeLarge);