views:

111

answers:

1

This is probably related to this question. I want to know if anyone else gets the same error as me and if there is a way to get around this.

I did the following:

  • Followed the instructions from this page.
  • From the top, go to File -> Create a new project -> Android Project -> Create project from existing sample.
  • Checked Android 2.2.
  • From the drop-down menu picked SkeletonApp.
  • Clicked finish.
  • From the package explorer, went to SkeletonActivity -> res -> layout -> skeleton_activity.xml.
  • In the tabs at the bottom of the editor area (editor area is the center of the screen) clicked on Layout.

Then I got the error "ClassCastException: android.widget.EditText cannot be cast to andoid.text.ViewGroup". The full text of the error message is given below.

java.lang.ClassCastException: android.widget.EditText cannot be cast to android.view.ViewGroup
at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:296)
at com.android.layoutlib.bridge.Bridge.computeLayout(Bridge.java:397)
at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.computeLayout(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.recomputeLayout(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.onConfigurationChange(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.onTargetChange(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.onDescriptorsChanged(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.initUiRootNode(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor$1.updateEditor(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor$1.onTargetLoaded(Unknown Source)
at com.android.ide.eclipse.adt.AdtPlugin$16.run(Unknown Source)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
A: 

Not sure if you got past this error but for anyone that didn't:

The offending bit of code is here:

<EditText android:id="@+id/editor"
    android:layout_width="fill_parent" android:layout_height="0dip"
    android:autoText="true"
    android:capitalize="sentences"
    android:layout_weight="1"
    android:freezesText="true" >
    <requestFocus />
</EditText>

I don't know why yet but through trial and error it is the requestFocus element that causes the problem. Delete that line and the Layout view will work again.

Adam