我的日志中出现错误,因此我没有看到图像,而是看不到图像。
12-07 12:45:42.988: W/ResourceType(19347): No package identifier when getting value for resource number 0x0000000d
12-07 12:45:42.990: W/ImageView(19347): Unable to find resource: 13
12-07 12:45:42.990: W/ImageView(19347): android.content.res.Resources$NotFoundException: Resource ID #0xd
12-07 12:45:42.990: W/ImageView(19347): at android.content.res.Resources.getValue(Resources.java:1019)
12-07 12:45:42.990: W/ImageView(19347): at android.content.res.Resources.getDrawable(Resources.java:663)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ImageView.resolveUri(ImageView.java:542)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ImageView.onMeasure(ImageView.java:647)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.measure(View.java:12773)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.measure(View.java:12773)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.setupChild(ListView.java:1878)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.makeAndAddView(ListView.java:1788)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.fillDown(ListView.java:676)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.fillSpecific(ListView.java:1335)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.ListView.layoutChildren(ListView.java:1613)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.AbsListView.onLayout(AbsListView.java:1910)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1633)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1491)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.LinearLayout.onLayout(LinearLayout.java:1404)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
12-07 12:45:42.990: W/ImageView(19347): at android.view.View.layout(View.java:11315)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewGroup.layout(ViewGroup.java:4314)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1602)
12-07 12:45:42.990: W/ImageView(19347): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2583)
12-07 12:45:42.990: W/ImageView(19347): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 12:45:42.990: W/ImageView(19347): at android.os.Looper.loop(Looper.java:137)
12-07 12:45:42.990: W/ImageView(19347): at android.app.ActivityThread.main(ActivityThread.java:4503)
12-07 12:45:42.990: W/ImageView(19347): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 12:45:42.990: W/ImageView(19347): at java.lang.reflect.Method.invoke(Method.java:511)
12-07 12:45:42.990: W/ImageView(19347): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
12-07 12:45:42.990: W/ImageView(19347): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
12-07 12:45:42.990: W/ImageView(19347): at dalvik.system.NativeStart.main(Native Method)
我有一个图层列表drawable fr_dwlds.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/play_spare"/>
<item android:id="@+id/clip_dwl">
<clip
android:clipOrientation="horizontal"
android:drawable="@drawable/play_fill_free_download"
android:gravity="left" />
</item>
</layer-list>
图片play_spare和play_fill_free_download都在资源中,我检查过它们没问题。
以防万一,这是在我的代码中使用这个LayerDrawable:
LayerDrawable ld2= (LayerDrawable) ctx.getResources().getDrawable(R.drawable.fr_dwlds);
ClipDrawable cd2=(ClipDrawable) ld2.findDrawableByLayerId(R.id.clip_dwl);
Log.d("MyLog","download image !imagestatus="+p.imagestatus+" level="+(4300+(30*p.imagestatus)));
cd2.setLevel(4300+(30*p.imagestatus));
((ImageView) view.findViewById(R.id.ivImage)).setImageDrawable(ld2);
我试图删除这个fr_dwlds.xml文件,制作另一个文件,更改剪辑的ID - 没有任何帮助,但如果我只是复制此代码和资源而不将antything更改为新项目 - 每个工作都正常。
那么..问题是什么以及如何解决?