Hi guys,
I always encounter this problem but dont know what cause it.
06-05 15:14:33.369: E/Suysing Error(277): Binary XML file line #1: Error inflating class com.suysing.hsfa.views.CustomerListItem
Here are my codes.
XML Layout
Views
Adapter
I always encounter this problem but dont know what cause it.
06-05 15:14:33.369: E/Suysing Error(277): Binary XML file line #1: Error inflating class com.suysing.hsfa.views.CustomerListItem
Here are my codes.
XML Layout
Code:
<com.suysing.hsfa.views.CustomerListItem
android:id="@+id/CustomerListItem"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBox
android:id="@+id/customer_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:focusable="false"/>
<CheckBox
android:id="@+id/customer_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:focusable="false"/>
<TextView
android:id="@+id/customer_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:gravity="left"
android:textColor="@color/white"
android:width="0dp" />
<TextView
android:id="@+id/store_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".6"
android:gravity="left"
android:textColor="@color/white"
android:width="0dp" />
</com.suysing.hsfa.views.CustomerListItem>
Views
Code:
package com.suysing.hsfa.views;
import com.suysing.hsfa.R;
import com.suysing.hsfa.domain.CustomerRegistration;
import android.content.Context;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
public class CustomerListItem extends LinearLayout{
private CustomerRegistration customer;
private CheckBox trans_Tag;
private CheckBox trans_Sent;
private TextView trans_CustomerID;
private TextView trans_StoreName;
public CustomerListItem(Context context) {
super(context);
}
public void setCustomer(CustomerRegistration customer) {
this.customer = customer;
trans_Tag.setChecked(customer.getTag());
trans_Sent.setChecked(customer.getSent());
trans_CustomerID.setText(customer.getCustomerId());
trans_StoreName.setText(customer.getCustomerName());
}
protected void onFinishInflate() {
super.onFinishInflate();
trans_Tag = (CheckBox)findViewById(R.id.transaction_tag);
trans_Sent = (CheckBox)findViewById(R.id.transaction_status);
trans_CustomerID =(TextView)findViewById(R.id.customer_id);
trans_StoreName=(TextView)findViewById(R.id.store_name);
}
public CustomerRegistration getCustomer() {
return customer;
}
}
Adapter
Code:
package com.suysing.hsfa.adapter;
import java.util.ArrayList;
import com.suysing.hsfa.R;
import com.suysing.hsfa.domain.CustomerRegistration;
import com.suysing.hsfa.views.CustomerListItem;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class CustomerListAdapter extends BaseAdapter {
private ArrayList<CustomerRegistration> customer;
private Context context;
public CustomerListAdapter(ArrayList<CustomerRegistration> customer, Context context) {
super();
this.customer = customer;
this.context = context;
}
public int getCount() {
return customer.size();
}
public CustomerRegistration getItem(int position) {
return (null == customer)? null : customer.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
CustomerListItem cli = null;
try {
if (null==convertView){
cli = (CustomerListItem)View.inflate(context, R.layout.transaction_customer, null);
}else{
cli = (CustomerListItem)convertView;
}
cli.setCustomer(customer.get(position));
} catch (Exception e) {
Log.e("Suysing Error", e.getMessage());
}
return cli;
}
public void forceReload() {
notifyDataSetChanged();
}
}