HListView无法实例化Android Eclipse项目库

时间:2013-11-26 11:35:41

标签: android android-listview android-library

该库包含一个演示项目,我试过,它工作得很好。现在当我在我的项目中导入库时,在我的布局文件中添加了:

<it.sephiroth.android.library.widget.HListView
        android:id="@+id/hListView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/ImageView01"
        android:layout_marginTop="19dp" >
    </it.sephiroth.android.library.widget.HListView>

它与演示中的几乎相同,当我进入图形布局选项卡时出现以下错误。

    eclipse.buildId=v22.0.5-757759triedm
    java.version=1.6.0_27
    java.vendor=Sun Microsystems Inc.
    BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
    Framework arguments:  -product com.android.ide.eclipse.adt.package.product
    Command-line arguments:  -os linux -ws gtk -arch x86 -product com.android.ide.eclipse.adt.package.product

    Error
    Tue Nov 26 13:25:53 EET 2013
    it.sephiroth.android.library.widget.HListView failed to instantiate.

    java.lang.IllegalStateException: Cannot find resource 'hlv_overscroll_edge'
        at it.sephiroth.android.library.widget.EdgeEffect.<init>(EdgeEffect.java:144)
        at it.sephiroth.android.library.widget.AbsHListView.setOverScrollMode(AbsHListView.java:697)
        at android.view.View.<init>(View.java:3237)
        at android.view.View.<init>(View.java:3295)
        at android.view.ViewGroup.<init>(ViewGroup.java:427)
        at it.sephiroth.android.library.widget.AdapterView.<init>(AdapterView.java:224)
        at it.sephiroth.android.library.widget.AbsHListView.<init>(AbsHListView.java:630)
        at it.sephiroth.android.library.widget.HListView.<init>(HListView.java:151)
        at it.sephiroth.android.library.widget.HListView.<init>(HListView.java:147)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
        at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
        at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
        at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
        at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
        at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
        at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:372)
        at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:383)
        at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
        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:440)
        at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
        at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)
        at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ReloadListener.reloadLayoutSwt(GraphicalEditorPart.java:1777)
        at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ReloadListener.access$0(GraphicalEditorPart.java:1715)
        at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ReloadListener$1.run(GraphicalEditorPart.java:1709)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3537)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3189)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
        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:616)
        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)

我尝试重新启动/清理,检查路径;但没有任何效果。 可能是什么问题?或者我应该看看演示项目,使其与我的相似,以便它可以工作?


更新

这是我的布局:http://pastebin.com/L7d5idwE

3 个答案:

答案 0 :(得分:3)

我遇到了与此库相同的异常。就我而言,我使用aapt的{​​{1}}选项重命名我的清单包。这导致--rename-manifest-package的{​​{1}}类无法找到所需的资源,因为Resources#getIdentifier(String,String,String)要求原始包名称加载标识符,而不是重命名的包名称。我已提交pull request来解决此问题。

答案 1 :(得分:0)

xmlns:HListView="http://schemas.android.com/apk/res-auto"

在reletivelayout中添加它将起作用

答案 2 :(得分:0)

我在需要时使用了scrollView并设置了项gone。我不建议使用这个库,因为它非常不稳定,可能导致进一步的应用程序问题。