android – requestWindowFeature(Window.FEATURE_NO_TITLE);给出了例外

android – requestWindowFeature(Window.FEATURE_NO_TITLE);给出了例外,第1张

概述import android.content.pm.ActivityInfo;import android.os.Bundle;import android.preference.ListPreference;import android.preference.Preference;import android.preference.PreferenceActivity;import a
import androID.content.pm.ActivityInfo;import androID.os.Bundle;import androID.preference.ListPreference;import androID.preference.Preference;import androID.preference.PreferenceActivity;import androID.util.Log;import androID.vIEw.Window;import androID.vIEw.WindowManager;public class OptionsActivity extends PreferenceActivity { private ListPreference mListPreference; @OverrIDe protected voID onCreate (Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setRequestedOrIEntation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);  requestwindowFeature(Window.FEATURE_NO_Title);  getwindow().addFlags(WindowManager.LayoutParams.FLAG_FulLSCREEN);              getwindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FulLSCREEN);  addPreferencesFromresource(R.xml.options);  mListPreference = (ListPreference) findPreference("Listpreference");  mListPreference.setPersistent(false);   }}Exception Stacktrace is given below:01-27 12:35:51.920: ERROR/AndroIDRuntime(615): FATAL EXCEPTION: main01-27 12:35:51.920: ERROR/AndroIDRuntime(615): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.androID.game/com.androID.game.OptionsActivity}: androID.util.AndroIDRuntimeException: requestFeature() must be called before adding content01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2663)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.ActivityThread.access00(ActivityThread.java:125)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.os.Handler.dispatchMessage(Handler.java:99)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.os.Looper.loop(Looper.java:123)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.ActivityThread.main(ActivityThread.java:4627)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at java.lang.reflect.Method.invokeNative(Native Method)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at java.lang.reflect.Method.invoke(Method.java:521)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:626)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at dalvik.system.NativeStart.main(Native Method)01-27 12:35:51.920: ERROR/AndroIDRuntime(615): Caused by: androID.util.AndroIDRuntimeException: requestFeature() must be called before adding content01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at com.androID.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:172)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.Activity.requestwindowFeature(Activity.java:2719)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at com.androID.game.OptionsActivity.onCreate(OptionsActivity.java:20)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     at androID.app.ActivityThread.performlaunchActivity(ActivityThread.java:2627)01-27 12:35:51.920: ERROR/AndroIDRuntime(615):     ... 11 more
解决方法 在add / clearFlags()代码之后移动setRequestedOrIEntation()

编辑:如下所述,我没有看到它使用了preferenceActivity.
只是为了您的理解,这是您使用super.onCreate()调用的PreferenceActivity.onCreate():

@OverrIDeprotected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    requestwindowFeature(Window.FEATURE_NO_Title);    setContentVIEw(com.androID.internal.R.layout.preference_List_content);    mPreferenceManager = onCreatePreferenceManager();    getListVIEw().setScrollbarStyle(VIEw.SCRolLbarS_INSIDE_INSET);}

如果在super.onCreate()中已经请求了FEATURE_NO_Title,为什么还要求它?有时,如果您深入了解AndroID源代码,这将非常有用.

总结

以上是内存溢出为你收集整理的android – requestWindowFeature(Window.FEATURE_NO_TITLE);给出了例外全部内容,希望文章能够帮你解决android – requestWindowFeature(Window.FEATURE_NO_TITLE);给出了例外所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存