【问题标题】:Add view class defined in external lbrary project添加在外部库项目中定义的视图类
【发布时间】:2013-09-19 21:15:49
【问题描述】:

我创建了一个新的 GLView 组件以添加到不同的项目中。正确构建库后,我尝试将其添加到我的测试应用程序中的 xml 布局中,但它似乎无法正常工作,因为它会引发 classnotfound 异常。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lib="http://schemas.android.com/apk/res-auto"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" 
android:background="@android:color/darker_gray">

<com.exapmple.library.CustomView
android:id="@+id/glsurfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</RelativeLayout>

而外部项目里面的类是:

public class CustomView extends GLSurfaceView

【问题讨论】:

标签: android android-custom-view


【解决方案1】:

你如何将你的库附加到项目中?

作为 jar lib 还是作为库项目?

我想问题出在错误的配置上。可能是 jar 文件放在“lib”文件夹而不是“libs”中。

【讨论】:

  • 库项目。可以从代码中的任何位置调用它,因此它已正确导入。 XML 文件需要 lib 的命名空间定义。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-10-21
  • 1970-01-01
  • 2011-02-06
  • 1970-01-01
  • 1970-01-01
  • 2014-01-26
  • 2014-03-17
相关资源
最近更新 更多