导航抽屉应用程序在加载时崩溃

时间:2014-06-30 09:22:04

标签: android exception fragment navigation-drawer

我正在制作兼容v4和v7的应用。该应用程序还具有Drawerlist项目和片段,用于改进的UI。它在模拟器上运行良好但是当我将其移植到我的Android手机上时,它会崩溃并显示以下日志。该应用程序在导航抽屉定制适配器充气机上有错误。它的代码也在下面。请帮忙。

 @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        if (convertView == null)
        {
            LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
            convertView = mInflater.inflate(R.layout.fragment_navigation_drawer, null);
            //the line above is causing trouble
        }

        ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
        TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
        TextView txtCount = (TextView) convertView.findViewById(R.id.counter);

        imgIcon.setImageResource(navDrawerItems.get(position).getIcon());
        txtTitle.setText(navDrawerItems.get(position).getTitle());

        // displaying count
        // check whether it set visible or not
        if(navDrawerItems.get(position).getCounterVisibility())
        {
            txtCount.setText(navDrawerItems.get(position).getCount());
        }
        else
        {
            // hide the counter view
            txtCount.setVisibility(View.GONE);
        }

        return convertView;
    }



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:background="@drawable/list_selector">

    <ImageView
        android:id="@+id/icon"
        android:layout_width="25dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        android:contentDescription="@string/desc_list_item_icon"
        android:src="@drawable/ic_nowplaying"
        android:layout_centerVertical="true" />

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_toRightOf="@id/icon"
        android:minHeight="?android:attr/listPreferredItemHeightSmall"
        android:textAppearance="?android:attr/textAppearanceListItemSmall"
        android:textColor="@color/list_item_title"
        android:gravity="center_vertical"
        android:paddingRight="40dp"
        tools:ignore="NewApi" />

    <TextView android:id="@+id/counter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/counter_bg"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="8dp"
        android:textColor="@color/counter_text_color"/>

</RelativeLayout>





06-30 14:02:01.889    2146-2146/aliabbasjaffri.pakcinemaguide E/ListView﹕ Binary XML file line #19: Error inflating class <unknown>
    android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
            at android.view.LayoutInflater.createView(LayoutInflater.java:518)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at aliabbasjaffri.pakcinemaguide.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:54)
            at android.widget.AbsListView.obtainView(AbsListView.java:1449)
            at android.widget.ListView.makeAndAddView(ListView.java:1801)
            at android.widget.ListView.fillSpecific(ListView.java:1339)
            at android.widget.ListView.layoutChildren(ListView.java:1637)
            at android.widget.AbsListView.onLayout(AbsListView.java:1279)
            at android.view.View.layout(View.java:7321)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            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:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at aliabbasjaffri.pakcinemaguide.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:54)
            at android.widget.AbsListView.obtainView(AbsListView.java:1449)
            at android.widget.ListView.makeAndAddView(ListView.java:1801)
            at android.widget.ListView.fillSpecific(ListView.java:1339)
            at android.widget.ListView.layoutChildren(ListView.java:1637)
            at android.widget.AbsListView.onLayout(AbsListView.java:1279)
            at android.view.View.layout(View.java:7321)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
            at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
            at android.view.View.<init>(View.java:2156)
            at android.widget.TextView.<init>(TextView.java:401)
            at android.widget.TextView.<init>(TextView.java:394)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at aliabbasjaffri.pakcinemaguide.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:54)
            at android.widget.AbsListView.obtainView(AbsListView.java:1449)
            at android.widget.ListView.makeAndAddView(ListView.java:1801)
            at android.widget.ListView.fillSpecific(ListView.java:1339)
            at android.widget.ListView.layoutChildren(ListView.java:1637)
            at android.widget.AbsListView.onLayout(AbsListView.java:1279)
            at android.view.View.layout(View.java:7321)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            at dalvik.system.NativeStart.main(Native Method)
06-30 14:02:01.959    2146-2146/aliabbasjaffri.pakcinemaguide E/ListView﹕ Binary XML file line #19: Error inflating class <unknown>
    android.view.InflateException: Binary XML file line #19: Error inflating class <unknown>
            at android.view.LayoutInflater.createView(LayoutInflater.java:518)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at aliabbasjaffri.pakcinemaguide.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:54)
            at android.widget.AbsListView.obtainView(AbsListView.java:1449)
            at android.widget.ListView.makeAndAddView(ListView.java:1801)
            at android.widget.ListView.fillSpecific(ListView.java:1339)
            at android.widget.ListView.layoutChildren(ListView.java:1637)
            at android.widget.AbsListView.onLayout(AbsListView.java:1279)
            at android.view.View.layout(View.java:7321)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            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:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at aliabbasjaffri.pakcinemaguide.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:54)
            at android.widget.AbsListView.obtainView(AbsListView.java:1449)
            at android.widget.ListView.makeAndAddView(ListView.java:1801)
            at android.widget.ListView.fillSpecific(ListView.java:1339)
            at android.widget.ListView.layoutChildren(ListView.java:1637)
            at android.widget.AbsListView.onLayout(AbsListView.java:1279)
            at android.view.View.layout(View.java:7321)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
            at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
            at android.view.View.<init>(View.java:2156)
            at android.widget.TextView.<init>(TextView.java:401)
            at android.widget.TextView.<init>(TextView.java:394)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
            at android.view.LayoutInflater.createView(LayoutInflater.java:505)
            at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
            at aliabbasjaffri.pakcinemaguide.NavDrawerListAdapter.getView(NavDrawerListAdapter.java:54)
            at android.widget.AbsListView.obtainView(AbsListView.java:1449)
            at android.widget.ListView.makeAndAddView(ListView.java:1801)
            at android.widget.ListView.fillSpecific(ListView.java:1339)
            at android.widget.ListView.layoutChildren(ListView.java:1637)
            at android.widget.AbsListView.onLayout(AbsListView.java:1279)
            at android.view.View.layout(View.java:7321)
            at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:767)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
            at android.view.View.layout(View.java:7321)
            at android.view.ViewRoot.performTraversals(ViewRoot.java:1217)
            at android.view.ViewRoot.handleMessage(ViewRoot.java:1995)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            at dalvik.system.NativeStart.main(Native Method)
06-30 14:02:27.313    2146-2146/aliabbasjaffri.pakcinemaguide E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoSuchMethodError: aliabbasjaffri.pakcinemaguide.MainActivity.invalidateOptionsMenu
            at aliabbasjaffri.pakcinemaguide.MainActivity$1.onDrawerOpened(MainActivity.java:153)
            at android.support.v4.widget.DrawerLayout.dispatchOnDrawerOpened(DrawerLayout.java:541)
            at android.support.v4.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:503)
            at android.support.v4.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:1408)
            at android.support.v4.widget.ViewDragHelper.setDragState(ViewDragHelper.java:866)
            at android.support.v4.widget.ViewDragHelper$2.run(ViewDragHelper.java:335)
            at android.os.Handler.handleCallback(Handler.java:587)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:150)
            at android.app.ActivityThread.main(ActivityThread.java:4389)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
            at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案