Note that there are some explanatory texts on larger screens.

plurals
  1. POError referencing an inner class View in layout/main.xml
    primarykey
    data
    text
    <p>Grrr...</p> <p>I create a subclass of view as an inner class in my Activity. Before I simply linked to this view from my activity with:</p> <pre><code>setContentView(new CustomView(this)); </code></pre> <p>without problems.</p> <p>Now, however, my view is getting more complex so I am making it part of a FrameLayout so that I can make this the base view and add a Spinner widget on top of it. The problem is, when I do this I get an error:</p> <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.grafightscratch.ochemmer/com.grafightscratch.ochemmer.MoleculeTablet}: android.view.InflateException: Binary XML file line #4: Error inflating class com.grafightscratch.ochemmer.MoleculeTablet.MoleculeTabletView ... Caused by: android.view.InflateException: Binary XML file line #4: Error inflating class com.grafightscratch.ochemmer.MoleculeTablet.MoleculeTabletView ... Caused by: java.lang.ClassNotFoundException: com.grafightscratch.ochemmer.MoleculeTablet.MoleculeTabletView in loader dalvik.system.PathClassLoader@43b74a28 </code></pre> <p>So- this view worked before when I linked to it directly, but when I tried to add it in the main.xml file as part of a framelayout I got the above error. I also tried putting into a layout with only it being displayed via:</p> <pre><code>&lt;com.grafightscratch.ochemmer.MoleculeTablet.MoleculeTabletView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/molecule_tablet_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre> <p>Nothing works. I keep getting the InflateException/ClassNotFoundException errors. It complains about "line #3" in the binary XML file, and if it is talking about main.xml that is the package declaration which I have triple checked.</p> <p><strong>EDIT</strong> I tried making this view a separate class (ie- not an inner class) and it works. After some searching around I found some posts saying that the xml tag should look like this:</p> <pre><code>&lt;com.grafightscratch.ochemmer.MoleculeTablet$MoleculeTabletView ...&gt; </code></pre> <p>Ie, a dollar sign should be used to separate the innerclass from the main class. However, Eclipse barfs on this, calls it an error, and refuses to let me build or deploy with that character there. So now the question becomes: how does one reference a View that is an inner class?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    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