2011-09-12 17 views
0

QuickContactBadgeをカスタムダイアログで使用しようとしています。私がqcbを修正しようとすると、いつもクラッシュしますが、なぜそれが見つからないのですか?誰も助けることができますか?前もって感謝します。QuickContactBadge in Custom Dialog

custom_xml.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
android:id="@+id/layout_root" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="10dp" 
xmlns:android="http://schemas.android.com/apk/res/android" 
> 
<QuickContactBadge 
android:id="@+id/quickContactBadge" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/quick_contact_badge" 
android:padding="5dp" 
></QuickContactBadge> 
</RelativeLayout> 

Javaコード:

Dialog dialog = new Dialog(NameOfActivity.this); 
dialog.setContentView(R.layout.custom_xml); 
dialog.show(); 

QuickContactBadge qcb = (QuickContactBadge) findViewById (R.id.quickContactBadge); 
//This make app always crash 
qcb.setMode(ContactsContract.QuickContact.MODE_LARGE); 
qcb.assignContactFromPhone("12345678", true); 
qcb.setImageResource(R.drawable.icon); 
+0

エラーログを送信できますか。 – PedroAGSantos

答えて

0

あなたはNullPointerExceptionを取得する必要があります。ダイアログオブジェクトにfindViewById()を呼び出します。

QuickContactBadge qcb = (QuickContactBadge) 
           dialog.findViewById (R.id.quickContactBadge); 
+0

ありがとうuserSeven7s:)、それは今働いている、私はとても愚かな間違いをした:( – Michalsx