I am unable to inflate a xml(layout containing QuickContactBadge) file using LayoutInflater, to use it inside ListView. It is not producing either compile/run time error or proper expected output. After I removed QuickContactBadge from XML Layout file, It gets inflated properly. How to solve this issue?
- Is it possible to inflate a XML layout file which have QuickContactBadge?
- If it is possible, What is the correct procedure to inflate a XML layout file which have QuickContactBadge, to use inside ListView?
Edit
message_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lLayoutMessageItemHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<QuickContactBadge
android:id="@+id/quickContactBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/lLayoutContentDisplayHolder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="@+id/tvPerson"
android:textIsSelectable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/strPerson"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvMessage"
android:textIsSelectable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/strLastMessage" />
<TextView
android:id="@+id/tvTime"
android:textIsSelectable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/strLastMessageReceivedTime" />
</LinearLayout>
</LinearLayout>
Edit: Updated code And getView() method of ContactListAdapter.java
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
if(context != null){
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View linearLayout = inflater.inflate(R.layout.message_item, null);
Contact contact = (Contact)getItem(position);
TextView tvPerson = (TextView)linearLayout.findViewById(R.id.tvPerson);
tvPerson.setText("Sample Text");
Log.i("Test","Sample Text");
return linearLayout;
}else{
return null;
}
}
Console Output:
07-10 17:00:26.511: I/Test(3574): Sample Text
07-10 17:00:26.611: I/Test(3574): Sample Text
07-10 17:00:26.621: I/Test(3574): Sample Text
07-10 17:00:26.641: I/Test(3574): Sample Text
07-10 17:00:26.661: I/Test(3574): Sample Text
07-10 17:00:26.691: I/Test(3574): Sample Text
07-10 17:00:26.701: I/Test(3574): Sample Text
P.S: Am not setting values for all the widgets used in that layout. I expected the list with only person name but It is not producing any error while compiling and also while running. But it displays only empty screen.