3

こんにちは私はアクションバーにアニメーションビューを追加しようとしていますが、Android 2.3でこのエラーが発生します(Android 4で動作します)

  1194         AndroidRuntime  E  FATAL EXCEPTION: main
  1194         AndroidRuntime  E  android.view.InflateException: Binary XML file line #3: Error inflating class <unknown>
  1194         AndroidRuntime  E    at android.view.LayoutInflater.createView(LayoutInflater.java:518)
  1194         AndroidRuntime  E    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
  1194         AndroidRuntime  E    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
  1194         AndroidRuntime  E    at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
  1194         AndroidRuntime  E    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
  1194         AndroidRuntime  E    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
  1194         AndroidRuntime  E    at it.patrick91.unisamenu.MainActivity.load(MainActivity.java:165)
  1194         AndroidRuntime  E    at it.patrick91.unisamenu.MainActivity.onOptionsItemSelected(MainActivity.java:219)
  1194         AndroidRuntime  E    at com.actionbarsherlock.app.SherlockListActivity.onMenuItemSelected(SherlockListActivity.java:208)
  1194         AndroidRuntime  E    at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
  1194         AndroidRuntime  E    at com.actionbarsherlock.internal.ActionBarSherlockCompat.onMenuItemSelected(ActionBarSherlockCompat.java:529)
  1194         AndroidRuntime  E    at com.actionbarsherlock.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:738)
  1194         AndroidRuntime  E    at com.actionbarsherlock.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:148)
  1194         AndroidRuntime  E    at com.actionbarsherlock.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:879)
  1194         AndroidRuntime  E    at com.actionbarsherlock.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:510)
  1194         AndroidRuntime  E    at com.actionbarsherlock.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:145)
  1194         AndroidRuntime  E    at android.view.View.performClick(View.java:2485)
  1194         AndroidRuntime  E    at android.view.View$PerformClick.run(View.java:9080)
  1194         AndroidRuntime  E    at android.os.Handler.handleCallback(Handler.java:587)
  1194         AndroidRuntime  E    at android.os.Handler.dispatchMessage(Handler.java:92)
  1194         AndroidRuntime  E    at android.os.Looper.loop(Looper.java:130)
  1194         AndroidRuntime  E    at android.app.ActivityThread.main(ActivityThread.java:3687)
  1194         AndroidRuntime  E    at java.lang.reflect.Method.invokeNative(Native Method)
  1194         AndroidRuntime  E    at java.lang.reflect.Method.invoke(Method.java:507)
  1194         AndroidRuntime  E    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  1194         AndroidRuntime  E    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
  1194         AndroidRuntime  E    at dalvik.system.NativeStart.main(Native Method)
  1194         AndroidRuntime  E  Caused by: java.lang.reflect.InvocationTargetException
  1194         AndroidRuntime  E    at java.lang.reflect.Constructor.constructNative(Native Method)
  1194         AndroidRuntime  E    at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
  1194         AndroidRuntime  E    at android.view.LayoutInflater.createView(LayoutInflater.java:505)
  1194         AndroidRuntime  E    ... 26 more
  1194         AndroidRuntime  E  Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01000f a=3}
  1194         AndroidRuntime  E    at android.content.res.Resources.loadDrawable(Resources.java:1681)
  1194         AndroidRuntime  E    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
  1194         AndroidRuntime  E    at android.view.View.<init>(View.java:1951)
  1194         AndroidRuntime  E    at android.widget.ImageView.<init>(ImageView.java:112)
  1194         AndroidRuntime  E    at android.widget.ImageView.<init>(ImageView.java:108)
  1194         AndroidRuntime  E    ... 29 more

画像を膨らませるコードは次のとおりです。

LayoutInflater inflater = (LayoutInflater) getApplication()
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView iv = (ImageView) inflater.inflate(R.layout.load_action_view,
        null);
Animation rotation = AnimationUtils.loadAnimation(getApplication(),
        R.anim.load_anim);
rotation.setRepeatCount(Animation.INFINITE);
iv.startAnimation(rotation); 

load_action_view.xmlは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/Widget.Sherlock.ActionButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_action_load" />

いくつかのテストを行って、style = "@ style/Widget.Sherlock.ActionButton"を削除すると問題が解決することに気づきました。

マニフェストの私のアプリケーションタグはこれです:

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Sherlock" >..</application>

何が問題なのか知っていますか?

4

1 に答える 1

4

getApplication()をこれに変更するのを修正しました(これはアクティビティ内にありました)

于 2012-12-06T00:55:12.240 に答える