Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid layout previewer throws error when adding custom LinearLayout
    primarykey
    data
    text
    <p>I've defined a custom ViewGroup that extends the functionality of a LinearLayout:</p> <pre><code>public class TestLayout extends LinearLayout { public TestLayout(Context context, AttributeSet attrs) { super(context, attrs); LayoutInflater inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.testlayout, this, true); } } </code></pre> <p>The layout it inflates (<strong>testlayout.xml</strong>) looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center"&gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>And finally i'm using this custom component in my <strong>main.xml</strong>:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;my.test.namespace.TestLayout android:id="@+id/testLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/my.test.namespace.TestLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>When viewing my main.xml in the layout editor, eclipse throws an error: <em>my.test.namespace.TestLayout failed to instantiate.</em></p> <p>And the stacktrace:</p> <pre><code>android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F030001. at com.android.layoutlib.bridge.android.BridgeResources.throwException(BridgeResources.java:648) at com.android.layoutlib.bridge.android.BridgeResources.getLayout(BridgeResources.java:270) at android.view.LayoutInflater.inflate(LayoutInflater.java:318) at my.test.namespace.TestLayout.&lt;init&gt;(TestLayout.java:18) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:397) at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:165) at com.android.layoutlib.bridge.android.BridgeInflater.loadCustomView(BridgeInflater.java:205) at com.android.layoutlib.bridge.android.BridgeInflater.createViewFromTag(BridgeInflater.java:133) at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) at android.view.LayoutInflater.inflate(LayoutInflater.java:407) </code></pre> <p><strong>0x7F030001</strong> points to the layout xml file in R.java. I tried cleaning my project, but that did nothing. Am I using the LayoutInflater wrong, or what is going on here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload