Hi Everyone,
I'm trying to inflate a custom layout from XML but there is an error
in an ImageView. Here is the custom component:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="#ffffff"
>
<ImageView
android:id="@+id/location_icon"
android:layout_marginRight="5dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/location_search"
/>
<TextView
android:id="@+id/location_text"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/location_icon"
android:layout_width="wrap_content"
android:text="Finding Location..."
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"
android:typeface="sans"
/>
</RelativeLayout>
Here's how I try to inflate it using the LayoutInflater:
LayoutInflater layoutInflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
location_frame = layoutInflater.inflate(R.layout.location_frame,
this);
Here is the logcat:
07-28 23:15:48.612: ERROR/AndroidRuntime(3797): Uncaught handler:
thread main exiting due to uncaught exception
07-28 23:15:48.662: ERROR/AndroidRuntime(3797):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.android.whatsthis/com.android.whatsthis.AppMain}:
android.view.InflateException: Binary XML file line #16: Error
inflating class com.android.whatsthis.LocationFrame
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2454)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2470)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.os.Looper.loop(Looper.java:123)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.ActivityThread.main(ActivityThread.java:4310)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
java.lang.reflect.Method.invokeNative(Native Method)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
java.lang.reflect.Method.invoke(Method.java:521)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
dalvik.system.NativeStart.main(Native Method)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): Caused by:
android.view.InflateException: Binary XML file line #16: Error
inflating class com.android.whatsthis.LocationFrame
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.createView(LayoutInflater.java:513)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.parseInclude(LayoutInflater.java:702)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:614)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:
198)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.Activity.setContentView(Activity.java:1622)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
com.android.whatsthis.AppMain.onCreate(AppMain.java:44)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2417)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): ... 11 more
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): Caused by:
java.lang.reflect.InvocationTargetException
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
com.android.whatsthis.LocationFrame.<init>(LocationFrame.java:48)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
java.lang.reflect.Constructor.constructNative(Native Method)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
java.lang.reflect.Constructor.newInstance(Constructor.java:446)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.createView(LayoutInflater.java:500)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): ... 23 more
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): Caused by:
android.view.InflateException: Binary XML file line #8: Error
inflating class android.widget.ImageView
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.createView(LayoutInflater.java:513)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:
56)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): ... 27 more
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): Caused by:
java.lang.reflect.InvocationTargetException
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.widget.ImageView.<init>(ImageView.java:105)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
java.lang.reflect.Constructor.constructNative(Native Method)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
java.lang.reflect.Constructor.newInstance(Constructor.java:446)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.view.LayoutInflater.createView(LayoutInflater.java:500)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): ... 33 more
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): Caused by:
android.content.res.Resources$NotFoundException: Resource is not a
Drawable (color or path): TypedValue{t=0x1/d=0x7f020002 a=-1
r=0x7f020002}
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.content.res.Resources.loadDrawable(Resources.java:1677)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.content.res.TypedArray.getDrawable(TypedArray.java:548)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): at
android.widget.ImageView.<init>(ImageView.java:115)
07-28 23:15:48.662: ERROR/AndroidRuntime(3797): ... 37 more
If I remove the src tag from the ImageView in the component it does
not produce this error.
Any thoughts as to what's causing it?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en