无法膨胀片段InflateException错误膨胀类

时间:2017-04-27 07:50:56

标签: android android-layout fatal-error layout-inflater

我制作左侧有简单抽屉菜单的项目,我用空白制作它给了我android工作室,然后我制作片段,然后点击抽屉菜单项主要内容布局更改为我需要的片段,在我的索尼xperia所有工作正常没有崩溃,但后来我安装在平板电脑,然后我点击它崩溃的抽屉菜单项,我不知道那米,有人可以在片段类中显示我onCreateView

 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    inflater = (LayoutInflater) getActivity().getSystemService (Context.LAYOUT_INFLATER_SERVICE);

    navigationView.getMenu().findItem(R.id.nav_kontakti).setChecked(true);
    if(rootView==null){
        rootView = inflater.inflate(R.layout.fragment_kontakti, container, false);
        findallcallbuttons();

    }

    return rootView;

}

这是错误

  FATAL EXCEPTION: main
    Process: *****************, PID: 31958
    android.view.InflateException: Binary XML file line #45: Error inflating class <unknown>
        at android.view.LayoutInflater.createView(LayoutInflater.java:620)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at ******************.fragments.KontaktiFragment.onCreateView(KontaktiFragment.java:43)
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
        at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
        at android.os.Handler.handleCallback(Handler.java:808)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:5292)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
        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:423)
        at android.view.LayoutInflater.createView(LayoutInflater.java:594)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
        at ******************.fragments.KontaktiFragment.onCreateView(KontaktiFragment.java:43) 
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) 
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) 
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) 
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) 
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) 
        at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) 
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) 
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710) 
        at android.os.Handler.handleCallback(Handler.java:808) 
        at android.os.Handler.dispatchMessage(Handler.java:103) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:5292) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
        at dalvik.system.NativeStart.main(Native Method) 
     Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0200a4 a=-1 r=0x7f0200a4}
        at android.content.res.Resources.loadDrawable(Resources.java:2124)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
        at android.view.View.<init>(View.java:3579)
        at android.view.ViewGroup.<init>(ViewGroup.java:494)
        at android.widget.LinearLayout.<init>(LinearLayout.java:188)
        at android.widget.LinearLayout.<init>(LinearLayout.java:183)
        at java.lang.reflect.Constructor.constructNative(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
        at ********.fragments.KontaktiFragment.onCreateView(KontaktiFragment.java:43) 
        at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) 
        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) 
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) 
        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) 
        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) 
        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) 
        at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) 
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013) 
        at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710) 
        at android.os.Handler.handleCallback(Handler.java:808) 
        at android.os.Handler.dispatchMessage(Handler.java:103) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:5292) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640) 
        at dalvik.system.NativeStart.main(Native Method) 

1 个答案:

答案 0 :(得分:0)

this is layout 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context="*********.fragments.KontaktiFragment">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="****"
        android:textColor="@color/bluedark"
        android:textSize="25sp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="5dp"
        android:text="******"
        android:textColor="@android:color/black"
        android:textSize="20sp" />


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="7dp"
        android:layout_marginLeft="7dp"
        android:layout_marginRight="7dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/rectangle_bluelight"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textview_vidnoe1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center"
                    android:paddingLeft="3dp"
                    android:paddingRight="3dp"
                    android:text="******"
                    android:textColor="@color/greenlight1"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <TextView
                    android:drawableRight="@drawable/ic_keyboard_arrow_right_white_24dp"
                    android:id="@+id/textview_vidnoe2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="3dp"
                    android:gravity="center"
                    android:padding="5dp"
                    android:text="*****"
                    android:textColor="@android:color/white"
                    android:textSize="15sp" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/kontacticall11"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="******"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall12"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/kontacticall13"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*******"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall14"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal"
                    android:weightSum="4">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text=""
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall15"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_weight="2"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text=""
                        android:textColor="@android:color/white" />
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/rectangle_bluelight"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textview_kol1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center"
                    android:paddingLeft="3dp"
                    android:paddingRight="3dp"
                    android:text="******"
                    android:textColor="@color/greenlight1"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <TextView
                    android:drawableRight="@drawable/ic_keyboard_arrow_right_white_24dp"
                    android:id="@+id/textview_kol2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="3dp"
                    android:gravity="center"
                    android:padding="5dp"
                    android:text="******"
                    android:textColor="@android:color/white"
                    android:textSize="15sp" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/kontacticall21"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="******"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall22"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal"
                    android:weightSum="4">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text=""
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall23"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_weight="2"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text=""
                        android:textColor="@android:color/white" />
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:background="@drawable/rectangle_bluelight"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textview_yar1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center"
                    android:paddingLeft="3dp"
                    android:paddingRight="3dp"
                    android:text="****"
                    android:textColor="@color/greenlight1"
                    android:textSize="22sp"
                    android:textStyle="bold" />

                <TextView
                    android:id="@+id/textview_yar2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="3dp"
                    android:drawableRight="@drawable/ic_keyboard_arrow_right_white_24dp"
                    android:gravity="center"
                    android:padding="5dp"
                    android:text="******"
                    android:textColor="@android:color/white"
                    android:textSize="15sp" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/kontacticall31"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall32"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="******"
                        android:textColor="@android:color/white" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="3dp"
                    android:layout_marginRight="3dp"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/kontacticall33"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall34"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal"
                    android:weightSum="4">

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text=""
                        android:textColor="@android:color/white" />

                    <TextView
                        android:id="@+id/kontacticall35"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_weight="2"
                        android:background="@drawable/rectangle_bluedark"
                        android:drawableLeft="@drawable/ic_call_white"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text="*****"
                        android:textColor="@android:color/white" />

                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:layout_marginTop="5dp"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:padding="5dp"
                        android:text=""
                        android:textColor="@android:color/white" />
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="15dp"></LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>