gpt4 book ai didi

java - Android:将外部项目包名称添加到布局xml中?

转载 作者:行者123 更新时间:2023-12-01 14:52:54 28 4
gpt4 key购买 nike

我的主项目中有一个 XML 布局文件,其中包含以下内容:

<com.quietlycoding.android.picker.NumberPicker
android:id="@+id/belegposition_belegpositionpickerpause"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

此包驻留在我已添加到构建路径中的另一个项目中。包名称 100% 正确。我还通过编译器能够识别的 .java 文件中的导入对此进行了测试。

但是当 XML 文件在运行时膨胀时,我收到此错误:

02-03 01:56:58.824: E/dalvikvm(4213): Could not find class 'com.quietlycoding.android.picker.NumberPicker', referenced from method de.innosoft.android.activity.BelegPositionen$ArrayAdapterBelegPosition.getView
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): Didn't find class "com.quietlycoding.android.picker.NumberPicker" on path: /system/framework/android.test.runner.jar:/data/app/de.innosoft.android-1.apk
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): java.lang.ClassNotFoundException: Didn't find class "com.quietlycoding.android.picker.NumberPicker" on path: /system/framework/android.test.runner.jar:/data/app/de.innosoft.android-1.apk
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at de.innosoft.android.activity.BelegPositionen$ArrayAdapterBelegPosition.getView(BelegPositionen.java:107)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.ListView.onMeasure(ListView.java:1158)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.View.measure(View.java:15513)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer.doFrame(Choreographer.java:532)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.os.Handler.handleCallback(Handler.java:725)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.os.Handler.dispatchMessage(Handler.java:92)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.os.Looper.loop(Looper.java:137)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at android.app.ActivityThread.main(ActivityThread.java:5191)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.reflect.Method.invokeNative(Native Method)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at java.lang.reflect.Method.invoke(Method.java:511)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
02-03 01:57:02.191: E/java.lang.ClassNotFoundException(4213): at dalvik.system.NativeStart.main(Native Method)

是否无法从 XML 文件引用外部项目包?或者我只是忘记了根 XML 元素的特定属性?

编辑:我正在使用外部项目,因为我不想用所有这些外部东西(绘图等)污染我的主项目文件夹。不幸的是,该库不是以 JAR 形式提供的。

最佳答案

尝试将外部项目添加为库。在外部项目中,转到项目属性,然后在 Android 部分中选中 Is Library 复选框。然后转到项目属性并在 Android 部分中将外部项目添加为库。

关于java - Android:将外部项目包名称添加到布局xml中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14668436/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com