3

由于我不是专家,我无法确定下面的错误是 logcat。我正在调用另一个页面onclick按钮。加载另一个页面时出现错误

setContentView(R.layout.searchm); 

下面是源代码和locgcat

Logcat如下

09-09 05:49:46.896: E/AndroidRuntime(2657): FATAL EXCEPTION: main
09-09 05:49:46.896: E/AndroidRuntime(2657): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androidhive.googlemaps/com.androidhive.googlemaps.SearchActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class CustomAutoCompleteTextView
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.os.Looper.loop(Looper.java:137)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at java.lang.reflect.Method.invokeNative(Native Method)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at java.lang.reflect.Method.invoke(Method.java:525)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at dalvik.system.NativeStart.main(Native Method)
09-09 05:49:46.896: E/AndroidRuntime(2657): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class CustomAutoCompleteTextView
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.Activity.setContentView(Activity.java:1895)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at com.androidhive.googlemaps.SearchActivity.onCreate(SearchActivity.java:26)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.Activity.performCreate(Activity.java:5133)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-09 05:49:46.896: E/AndroidRuntime(2657):     ... 11 more
09-09 05:49:46.896: E/AndroidRuntime(2657): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CustomAutoCompleteTextView" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.androidhive.googlemaps-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.androidhive.googlemaps-2, /vendor/lib, /system/lib]]
09-09 05:49:46.896: E/AndroidRuntime(2657):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.createView(LayoutInflater.java:559)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
09-09 05:49:46.896: E/AndroidRuntime(2657):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
09-09 05:49:46.896: E/AndroidRuntime(2657):     ... 21 more
4

4 回答 4

2

我认为您在布局 XML中使用类CustomAutoCompleteTextView(可能从 扩展),而不使用完整的类名(带包)。AutoCompleteTextView在这种情况下,Android 将自动尝试在包中查找此类android.view- 但在您的情况下,它无法这样做(因为那里不存在 calss)。您的 XML 很可能是这样的:

<CustomAutoCompleteTextView ...>

相反,对于自定义类,您需要使用包指定完整的类名 - 所以将其更改为

<com.your.package.CustomAutoCompleteTextView ...>
于 2013-09-09T12:29:25.750 回答
2

在你的 xml 文件中

<CustomAutoCompleteTextView

                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                   />

用。。。来代替

<YoupPckageNameSpecifiedInYourCustomview.CustomAutoCompleteTextView

                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                       />
于 2013-09-09T12:31:05.053 回答
0

如果您在运行 Android Api 的模拟器上运行项目,则使用带有Google-API 的模拟器运行/测试您的项目。

于 2013-09-09T12:28:40.270 回答
0

我认为您正在尝试引用一个应该是 AutoCompleteTextView 的类 CustomAutoCompleteTextView

“没有找到类“android.view.CustomAutoCompleteTextView””

您需要在自己的应用程序中定义此类或使用 android 类

于 2013-09-09T12:27:04.263 回答