android-使用Widget.Sherlock.ActionButton使ImageView膨胀时,资源不是可绘制的

android-使用Widget.Sherlock.ActionButton使ImageView膨胀时,资源不是可绘制的,第1张

概述嗨,我正在尝试向 *** 作栏添加动画视图,但是在Android2.3上出现此错误(在Android4上有效)1194AndroidRuntimeEFATALEXCEPTION:main1194AndroidRuntimeEandroid.view.InflateException:BinaryXMLfileline#3:Errorinflatingclass<unknown

嗨,我正在尝试向 *** 作栏添加动画视图,但是在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"        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>

你知道是什么问题吗?

解决方法:

修复了将getApplication()更改为此(它在Activity中)的问题

总结

以上是内存溢出为你收集整理的android-使用Widget.Sherlock.ActionButton使ImageView膨胀时,资源不是可绘制的全部内容,希望文章能够帮你解决android-使用Widget.Sherlock.ActionButton使ImageView膨胀时,资源不是可绘制的所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1086151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存