0

我有这个错误,它不会从我的 xml 编辑器显示图形布局......这是我的 Eclispe 上的错误日志上的消息和堆栈跟踪消息

activity_patient.xml: com.android.layoutlib.bridge.impl.binding.FakeAdapter cannot be cast to android.widget.BaseAdapter

堆栈跟踪

java.lang.ClassCastException: com.android.layoutlib.bridge.impl.binding.FakeAdapter cannot be cast to android.widget.BaseAdapter
    at android.widget.FastScroller.getSectionsFromIndexer(FastScroller.java:512)
    at android.widget.FastScroller.getThumbPositionForListPosition(FastScroller.java:633)
    at android.widget.FastScroller.onScroll(FastScroller.java:458)
    at android.widget.AbsListView.invokeOnItemScrollListener(AbsListView.java:1323)
    at android.widget.ListView.layoutChildren(ListView.java:1707)
    at android.widget.AbsListView.onLayout(AbsListView.java:2102)
    at android.view.View.layout(View.java:13754)
    at android.view.ViewGroup.layout(ViewGroup.java:4362)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
    at android.view.View.layout(View.java:13754)
    at android.view.ViewGroup.layout(ViewGroup.java:4362)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
    at android.view.View.layout(View.java:13754)
    at android.view.ViewGroup.layout(ViewGroup.java:4362)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
    at android.view.View.layout(View.java:13754)
    at android.view.ViewGroup.layout(ViewGroup.java:4362)
    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
    at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
    at android.view.View.layout(View.java:13754)
    at android.view.ViewGroup.layout(ViewGroup.java:4362)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:449)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:333)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1638)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1389)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1163)
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:674)
    at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360)
    at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:292)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1300)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1285)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1079)
    at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3023)
    at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1730)
    at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:270)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3554)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3179)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    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:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)

我不知道如何解决这个问题,因为当我运行我的模拟器时..我的布局运行正常..我无法轻松编辑它,我必须对其进行硬编码......任何输入都会有助于解决这个问题还是你们中的任何人都解决了这个问题,我的猜测是它在 adt 插件上..

顺便说一句,我正在使用 Juno Eclipse 和 ADT 最新版本

4

2 回答 2

1

这是自定义布局的一个已知问题。

可视化布局编辑器只加载它从 XML 中读取的类。基本上,当它在 XML 中找到一个不是默认小部件的节点时,它会要求 eclipse 加载相应的类。有可能我们所做的自定义类加载器实际上并没有处理加载的类需要从项目中加载另一个类的情况。

这是一个类似的问题

这是一个解决方案,虽然我自己没有尝试过..

于 2012-07-29T12:43:06.423 回答
0

ClassCastException如果您在一个屏幕上有多个滚动视图,您还将获得。例如,如果您有一个ListView内部 a ScrollView,您将看到此异常。幸运的是,Eclipse 强调了这个问题并显示了这一点:

垂直滚动的 ScrollView 不应包含另一个垂直滚动的小部件 (ListView)

当你将鼠标悬停在它上面时。

于 2012-07-31T17:08:15.240 回答