3

While inflating custom ListView row layout I'm getting this exception.

E/AndroidRuntime(1241): android.view.InflateException: Binary XML file line #6: Error inflating class <unknown>

See the code below for reference...

CustomListViewAdapter.java

public View getView(final int position, View convertView, ViewGroup parent) {
    holder = null;
    ListViewRowData rowItems = (ListViewRowData) getItem(position);

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);

    if (convertView == null) {
        convertView = inflater.inflate(R.layout.list_row, null); //<- throws inflate exception here

        holder = new ViewHolder();
        holder.dataFields = items.get(position);
        holder.mDeleteCB = (CheckBox) convertView
                .findViewById(R.id.DeleteCB);

        holder.mSeatName = (TextView) convertView.findViewById(R.id.SeatNo);
        holder.mAddDesc = (TextView) convertView
                .findViewById(R.id.CallDesc);
        holder.mCallIcon = (ImageView) convertView
                .findViewById(R.id.PaxCallIV);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.mSeatName.setText(rowItems.getSeatName());
    holder.mAddDesc.setText(rowItems.getAddDesc());

    holder.mCallIcon.setImageDrawable(context.getResources().getDrawable(
            R.drawable.ic_launcher));

    return convertView;
}

list_row.xml

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/SeatNo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:padding="15dp"
        android:text="Seat"
        android:textSize="@android:attr/textAppearanceMedium"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/CallDesc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/SeatNo"
        android:padding="15dp"
        android:text="Description :"
        android:textSize="@android:attr/textAppearanceMedium" />

    <ImageView
        android:id="@+id/PaxCallIV"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:padding="10dp"
        android:src="@drawable/ic_launcher" />

    <CheckBox
        android:id="@+id/DeleteCB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@id/PaxCallIV"
        android:paddingRight="15dp" />

</RelativeLayout>

Any kind of help or suggestion is much appreciated. Thanks !

Update

below is the entire logcat,

android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:613)
    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    at com.sample.ecabinservice.utility.CustomListViewAdapter.getView(CustomListViewAdapter.java:46)
    at android.widget.AbsListView.obtainView(AbsListView.java:2159)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
    at android.widget.ListView.onMeasure(ListView.java:1158)
    at android.view.View.measure(View.java:15513)
    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:645)
    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:425)
    at android.view.View.measure(View.java:15513)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
    at android.view.View.measure(View.java:15513)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
    at android.view.View.measure(View.java:15513)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
    at android.view.View.measure(View.java:15513)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
    at android.view.View.measure(View.java:15513)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
    at android.view.Choreographer.doCallbacks(Choreographer.java:562)
    at android.view.Choreographer.doFrame(Choreographer.java:532)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5039)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
    at android.view.LayoutInflater.createView(LayoutInflater.java:587)
    ... 48 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
    at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
    at android.widget.TextView.<init>(TextView.java:787)
    at android.widget.TextView.<init>(TextView.java:449)
4

1 回答 1

13

文本外观参考,如@android:attr/textAppearanceMedium,进入android:textAppearance属性,而不是android:textSize

于 2013-03-21T12:44:10.873 回答