由于我不是专家,我无法识别下面的错误是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
答案 0 :(得分:2)
我认为您在布局XML中使用类CustomAutoCompleteTextView
(可能从AutoCompleteTextView
扩展),而不使用完整的类名(包含)。在这种情况下,Android会自动尝试在包android.view
中找到此类 - 但在您的情况下,它无法这样做(因为那里没有calss)。最有可能的是,你的XML有这样的东西:
<CustomAutoCompleteTextView ...>
相反,对于自定义类,您需要使用包指定完整的类名 - 因此将其更改为
<com.your.package.CustomAutoCompleteTextView ...>
答案 1 :(得分: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"
/>
答案 2 :(得分:0)
我认为您正在尝试引用一个类CustomAutoCompleteTextView 什么时候应该是AutoCompleteTextView
“没找到类”android.view.CustomAutoCompleteTextView“”
您需要在自己的应用中定义此类,或者使用android one
答案 3 :(得分:0)
如果您在使用Android Api运行的模拟器上运行项目,则使用带有 Google-API 的模拟器运行/测试您的项目。