gpt4 book ai didi

android - Android 2.3.5 上的 ActionBar 和 SearchView 问题

转载 作者:行者123 更新时间:2023-11-29 18:07:30 25 4
gpt4 key购买 nike

我在我的应用程序中实现了一个 ActionBar 以及一个 SearchView 小部件。它在 Nexus 7、HTC Sensation 等设备上工作得很好——我相信任何 Android 版本早于 3.0 的地方。但它不能在 Android 2.3.5 的手机上运行。

当程序在旧设备上运行时,有没有办法“不显示”操作栏和其他不受支持的东西?

这是我在我的旧设备上运行时得到的错误日志,请原谅我的长度,不太明白哪个位有用:

09-27 12:15:03.008: I/dalvikvm(824): Failed resolving Lcom/example/stroke/handling/MainActivity; interface 407 'Landroid/widget/SearchView$OnQueryTextListener;'
09-27 12:15:03.008: W/dalvikvm(824): Link of class 'Lcom/example/stroke/handling/MainActivity;' failed
09-27 12:15:03.008: D/AndroidRuntime(824): Shutting down VM
09-27 12:15:03.008: W/dalvikvm(824): threadid=1: thread exiting with uncaught exception (group=0x400205a0)
09-27 12:15:03.018: E/AndroidRuntime(824): FATAL EXCEPTION: main
09-27 12:15:03.018: E/AndroidRuntime(824): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.stroke.handling/com.example.stroke.handling.MainActivity}: java.lang.ClassNotFoundException: com.example.stroke.handling.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.stroke.handling-1.apk]
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1743)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.os.Handler.dispatchMessage(Handler.java:99)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.os.Looper.loop(Looper.java:150)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.main(ActivityThread.java:4277)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.reflect.Method.invokeNative(Native Method)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.reflect.Method.invoke(Method.java:507)
09-27 12:15:03.018: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-27 12:15:03.018: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-27 12:15:03.018: E/AndroidRuntime(824): at dalvik.system.NativeStart.main(Native Method)
09-27 12:15:03.018: E/AndroidRuntime(824): Caused by: java.lang.ClassNotFoundException: com.example.stroke.handling.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.stroke.handling-1.apk]
09-27 12:15:03.018: E/AndroidRuntime(824): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-27 12:15:03.018: E/AndroidRuntime(824): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
09-27 12:15:03.018: E/AndroidRuntime(824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1735)
09-27 12:15:03.018: E/AndroidRuntime(824): ... 11 more

附言我不想使用 ActionBarSherlock!

最佳答案

哎呀,

Remaining backward-compatible

If you want to provide an action bar in your application and remain compatible with versions of Android older than 3.0, you need to create the action bar in your activity's layout (because the ActionBar class is not available on older versions).

To help you, the Action Bar Compatibility sample app provides an API layer and action bar layout that allows your app to use some of the ActionBar APIs and also support older versions of Android by replacing the traditional title bar with a custom action bar layout.

这是我问题的答案吗?

编辑:那个示例应用很糟糕。

关于android - Android 2.3.5 上的 ActionBar 和 SearchView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12620225/

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