android – 使用ActionBarCompat和requestWindowFeature

android – 使用ActionBarCompat和requestWindowFeature,第1张

概述到目前为止,我从ActionBarSherlock转移到ActionBarCompat没有更大的问题.在我的Nexus 4上,它的效果非常好.当我开始测试运行2.3.6的旧版Nexus One时,我在旋转设备时遇到了问题.我请求一个Window功能来显示ActionBar中的中间进度: @Overrideprotected void onCreate(final Bundle savedInst 到目前为止,我从ActionbarSherlock转移到ActionbarCompat没有更大的问题.在我的Nexus 4上,它的效果非常好.当我开始测试运行2.3.6的旧版Nexus One时,我在旋转设备时遇到了问题.我请求一个Window功能来显示Actionbar中的中间进度:
@OverrIDeprotected voID onCreate(final Bundle savedInstanceState){    super.onCreate(savedInstanceState);    requestwindowFeature(androID.vIEw.Window.FEATURE_PROGRESS);    requestwindowFeature(androID.vIEw.Window.FEATURE_INDETERMINATE_PROGRESS);    setupActionbar(getSupportActionbar());}

这对果冻豆很有效.

在2.3.6上获取此Stack Trace:

08-12 13:34:09.242: E/AndroIDRuntime(4602): FATAL EXCEPTION: main08-12 13:34:09.242: E/AndroIDRuntime(4602): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.app.packagename/net.app.fragment.CustomActivity}: androID.util.AndroIDRuntimeException: requestFeature() must be called before adding content08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:1647)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread.handle@R_29_4404@Activity(ActivityThread.java:2832)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread.access00(ActivityThread.java:117)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:935)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.os.Handler.dispatchMessage(Handler.java:99)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.os.Looper.loop(Looper.java:130)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread.main(ActivityThread.java:3683)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at java.lang.reflect.Method.invokeNative(Native Method)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at java.lang.reflect.Method.invoke(Method.java:507)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:597)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at dalvik.system.NativeStart.main(Native Method)08-12 13:34:09.242: E/AndroIDRuntime(4602): Caused by: androID.util.AndroIDRuntimeException: requestFeature() must be called before adding content08-12 13:34:09.242: E/AndroIDRuntime(4602):     at com.androID.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.Activity.requestwindowFeature(Activity.java:2729)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at net.app.fragment.BaseFragmentActivity.onCreate(BaseFragmentActivity.java:50)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at net.app.fragment.CustomActivity.onCreate(CustomActivity.java:55)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)08-12 13:34:09.242: E/AndroIDRuntime(4602):     at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:1611)08-12 13:34:09.242: E/AndroIDRuntime(4602):     ... 12 more08-12 13:34:12.092: I/Process(4602): Sending signal. PID: 4602 SIG: 9

谁知道如何解决这个问题?

问候

解决方法 调用supportRequestwindowFeature(Window.FEATURE _…).

见http://android-developers.blogspot.com/2013/08/actionbarcompat-and-io-2013-app-source.html

总结

以上是内存溢出为你收集整理的android – 使用ActionBarCompat和requestWindowFeature全部内容,希望文章能够帮你解决android – 使用ActionBarCompat和requestWindowFeature所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1132685.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存