listview_item_for_images.java
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/RestaurantNameImageTopID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:textColorHint="@color/TextColorForTextAboveImage" />
</RelativeLayout>
在这里,我在图像顶部放置了一个文本视图,它显示在列表视图中
我得到了成功的输出
但
如果我在 xml 属性中将文本颜色更改为白色并进行编译,则会出现以下错误
日志::
09-28 15:53:22.065: I/MemoryCache(2451): MemoryCache will use up to 8.0MB
09-28 15:53:22.445: D/dalvikvm(2451): GC_EXTERNAL_ALLOC freed 307K, 50% free 2966K/5895K, external 2130K/2137K, paused 102ms
09-28 15:53:22.465: I/MemoryCache(2451): cache size=47000 length=1
09-28 15:53:22.715: I/MemoryCache(2451): cache size=111500 length=2
09-28 15:53:22.795: I/MemoryCache(2451): cache size=168620 length=3
09-28 15:53:22.795: I/MemoryCache(2451): cache size=237060 length=4
09-28 15:53:24.685: D/dalvikvm(2451): GC_EXTERNAL_ALLOC freed 422K, 53% free 2805K/5895K, external 2709K/2713K, paused 82ms
09-28 15:53:26.855: I/MemoryCache(2451): MemoryCache will use up to 8.0MB
09-28 15:53:26.875: W/ResourceType(2451): Failure getting entry for 0x7f060000 (t=5 e=0) in package 0 (error -75)
09-28 15:53:26.885: D/AndroidRuntime(2451): Shutting down VM
09-28 15:53:26.885: W/dalvikvm(2451): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-28 15:53:26.945: E/AndroidRuntime(2451): FATAL EXCEPTION: main
09-28 15:53:26.945: E/AndroidRuntime(2451): android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
09-28 15:53:26.945: E/AndroidRuntime(2451): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-28 15:53:26.945: E/AndroidRuntime(2451): at com.project.findmybuffet.ListViewAdapterForImages.getView(ListViewAdapterForImages.java:60)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.ListView.makeAndAddView(ListView.java:1745)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.ListView.fillDown(ListView.java:670)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.ListView.fillFromTop(ListView.java:727)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.ListView.layoutChildren(ListView.java:1598)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.View.layout(View.java:7175)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.os.Handler.dispatchMessage(Handler.java:99)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.os.Looper.loop(Looper.java:123)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-28 15:53:26.945: E/AndroidRuntime(2451): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 15:53:26.945: E/AndroidRuntime(2451): at java.lang.reflect.Method.invoke(Method.java:507)
09-28 15:53:26.945: E/AndroidRuntime(2451): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-28 15:53:26.945: E/AndroidRuntime(2451): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-28 15:53:26.945: E/AndroidRuntime(2451): at dalvik.system.NativeStart.main(Native Method)
09-28 15:53:26.945: E/AndroidRuntime(2451): Caused by: java.lang.reflect.InvocationTargetException
09-28 15:53:26.945: E/AndroidRuntime(2451): at java.lang.reflect.Constructor.constructNative(Native Method)
09-28 15:53:26.945: E/AndroidRuntime(2451): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
09-28 15:53:26.945: E/AndroidRuntime(2451): ... 45 more
09-28 15:53:26.945: E/AndroidRuntime(2451): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.content.res.Resources.loadColorStateList(Resources.java:1804)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.TextView.<init>(TextView.java:649)
09-28 15:53:26.945: E/AndroidRuntime(2451): at android.widget.TextView.<init>(TextView.java:337)
09-28 15:53:26.945: E/AndroidRuntime(2451): ... 48 more