2013-03-06 188 views
1

我的要求是我想創建一個圖片聯繫人,並且在聯繫人圖片旁邊我想顯示聯繫人的姓名。如何在android中創建聯繫人

下面是我的代碼:在這裏我也可以創建聯繫人,但我無法獲得確切的輸出。

代碼:

<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

請任何人建議我。

謝謝。

回答

0

快速接觸徽章需要提供一些數據。如果你沒有應用任何數據,圓形頭+微笑圖像就是你得到的。你應該得到一個Uri並將其分配給徽章。

這裏是一個很好的教程由巴蒂爾康德&勞倫Darcey: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); 
相關問題