2

onCreateViewのこの行でActionBarSherlockを使用するダイアログフラグメントに奇妙な問題があります

LinearLayout root = (LinearLayout) inflater.inflate(com.example.R.layout.new_event_dialog_fragment, container, false);

これは私のActionBarSherlockプロジェクトマニフェストです:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>

そしてこれは私のアプリケーションターゲットです:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />

APIレベル10のエミュレーターでアプリを実行すると、次のエラーが発生します:

892: E/AndroidRuntime(645): FATAL EXCEPTION: main
09-12 10:00:38.892: E/AndroidRuntime(645): android.view.InflateException: Binary XML file line #26: Error inflating class android.view.View
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
09-12 10:00:38.892: E/AndroidRuntime(645):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-12 10:00:38.892: E/AndroidRuntime(645):  at com.example.gui.fragment.dialog.NewEventDialogFragment.onCreateView(NewEventDialogFragment.java:34)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.os.Handler.handleCallback(Handler.java:587)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.os.Looper.loop(Looper.java:123)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.app.ActivityThread.main(ActivityThread.java:3683)
09-12 10:00:38.892: E/AndroidRuntime(645):  at java.lang.reflect.Method.invokeNative(Native Method)
09-12 10:00:38.892: E/AndroidRuntime(645):  at java.lang.reflect.Method.invoke(Method.java:507)
09-12 10:00:38.892: E/AndroidRuntime(645):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-12 10:00:38.892: E/AndroidRuntime(645):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-12 10:00:38.892: E/AndroidRuntime(645):  at dalvik.system.NativeStart.main(Native Method)
09-12 10:00:38.892: E/AndroidRuntime(645): Caused by: java.lang.reflect.InvocationTargetException
09-12 10:00:38.892: E/AndroidRuntime(645):  at java.lang.reflect.Constructor.constructNative(Native Method)
09-12 10:00:38.892: E/AndroidRuntime(645):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
09-12 10:00:38.892: E/AndroidRuntime(645):  ... 21 more
09-12 10:00:38.892: E/AndroidRuntime(645): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x101030a a=-1}
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.content.res.Resources.loadDrawable(Resources.java:1681)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.View.<init>(View.java:1951)
09-12 10:00:38.892: E/AndroidRuntime(645):  at android.view.View.<init>(View.java:1899)
09-12 10:00:38.892: E/AndroidRuntime(645):  ... 24 more

APIレベル7のエミュレーターで実行すると、次のようなエラーが発生します。

09-12 10:15:02.035:E / AndroidRuntime(220):キャッチされていないh

Handler: thread main exiting due to uncaught exception
09-12 10:15:02.067: E/AndroidRuntime(220): android.view.InflateException: Binary XML file line #26: Error inflating class android.view.View
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.createView(LayoutInflater.java:513)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
09-12 10:15:02.067: E/AndroidRuntime(220):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-12 10:15:02.067: E/AndroidRuntime(220):  at com.example.gui.fragment.dialog.NewEventDialogFragment.onCreateView(NewEventDialogFragment.java:34)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.os.Handler.handleCallback(Handler.java:587)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.os.Looper.loop(Looper.java:123)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.app.ActivityThread.main(ActivityThread.java:4363)
09-12 10:15:02.067: E/AndroidRuntime(220):  at java.lang.reflect.Method.invokeNative(Native Method)
09-12 10:15:02.067: E/AndroidRuntime(220):  at java.lang.reflect.Method.invoke(Method.java:521)
09-12 10:15:02.067: E/AndroidRuntime(220):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
09-12 10:15:02.067: E/AndroidRuntime(220):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
09-12 10:15:02.067: E/AndroidRuntime(220):  at dalvik.system.NativeStart.main(Native Method)
09-12 10:15:02.067: E/AndroidRuntime(220): Caused by: java.lang.reflect.InvocationTargetException
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.View.<init>(View.java:1799)
09-12 10:15:02.067: E/AndroidRuntime(220):  at java.lang.reflect.Constructor.constructNative(Native Method)
09-12 10:15:02.067: E/AndroidRuntime(220):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.LayoutInflater.createView(LayoutInflater.java:500)
09-12 10:15:02.067: E/AndroidRuntime(220):  ... 21 more
09-12 10:15:02.067: E/AndroidRuntime(220): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/btn_dropdown.xml from drawable resource ID #0x0
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.content.res.Resources.loadDrawable(Resources.java:1693)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.view.View.<init>(View.java:1850)
09-12 10:15:02.067: E/AndroidRuntime(220):  ... 25 more
09-12 10:15:02.067: E/AndroidRuntime(220): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/btn_dropdown.xml from xml type drawable resource ID #0x0
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:1920)
09-12 10:15:02.067: E/AndroidRuntime(220):  at android.content.res.Resources.loadDrawable(Resources.java:1688)
09-12 10:15:02.067: E/AndroidRuntime(220):  ... 27 more

私のレイアウト

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


    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:padding="8dp">
        <TextView android:id="@+id/textView1" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:paddingRight="5dp"
            android:text="@string/event_name" android:textAppearance="?android:attr/textAppearanceSmall" />
        <EditText android:id="@+id/editText1" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="1"
            android:ems="10" android:inputType="textCapWords">
            <requestFocus />
        </EditText>
    </LinearLayout>
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content" android:padding="8dp">
        <TextView android:id="@+id/textView2" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_gravity="center_vertical"
            android:gravity="center_vertical" android:paddingRight="5dp"
            android:text="@string/currency" android:textAppearance="?android:attr/textAppearanceSmall" />
        <Spinner android:id="@+id/spinner1" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_gravity="center_vertical"
            android:layout_weight="1" />
    </LinearLayout>
    <View android:id="@+id/horizontal_divider_login"
        android:layout_width="match_parent" android:layout_height="1dp"
        android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
        android:layout_weight="0.35" android:background="?android:attr/dividerVertical"
        android:orientation="horizontal" />
    <LinearLayout android:layout_width="match_parent"
        android:layout_height="48dp" android:orientation="horizontal">
        <LinearLayout android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="0.5"
            android:gravity="center" android:orientation="vertical">
            <Button android:id="@+id/btn_abort"
                style="@android:style/Widget.Holo.Button.Borderless.Small"
                android:layout_width="match_parent" android:layout_height="wrap_content"
                android:text="@android:string/cancel" android:textColor="?android:attr/textColorPrimary" />
        </LinearLayout>
        <LinearLayout android:id="@+id/vertical_divider"
            android:layout_width="1dip" android:layout_height="match_parent"
            android:layout_marginBottom="4dp" android:layout_marginTop="4dp"
            android:background="?android:attr/dividerVertical" />
        <LinearLayout android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_weight="0.5"
            android:gravity="center" android:orientation="vertical">
            <Button android:id="@+id/btn_ok"
                style="@android:style/Widget.Holo.Button.Borderless.Small"
                android:layout_width="match_parent" android:layout_height="wrap_content"
                android:layout_weight="0.5" android:text="@android:string/ok"
                android:textColor="?android:attr/textColorPrimary" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

どちらの場合もリソースエラー(スピナーの解像度について考えます)のようですが、解決できません。完全にクリーンなAPIターゲットを変更してみますが、何もしません。ありがとう

PS:実際のデバイス(4.0.4)またはエミュレーター(4.1.1)で実行すると、すべて正常に動作します

4

1 に答える 1

3

1つまたは複数のリソースがドローアブルではないためにスローされた例外。xmlからこれを削除してみてください

android:background="?android:attr/dividerVertical"
于 2012-09-12T10:59:08.900 に答える