requestWindowFeature(Window.FEATURE_NO_TITLE); gives the exception

人走茶凉 提交于 2019-12-05 05:21:32

Move the setRequestedOrientation() after the add/clearFlags() code

Edit: as stated below, I didn't see that it's using a preferenceActivity. Just for your understanding, this is the PreferenceActivity.onCreate() which you call with super.onCreate():

@Override
protected 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);
}

Why you request FEATURE_NO_TITLE if this already is requested in the super.onCreate()? Sometimes it's very helpful if you dig into the Android source code.

In this case the super is setting the content view, and you must use requestWindowFeature before setting the content view. Thus use requestWindowFeature before calling the super.

public class LandNavSettings extends PreferenceActivity implements
            SharedPreferences.OnSharedPreferenceChangeListener {

    @Override
    protected void onCreate(Bundle icicle) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            super.onCreate(icicle);     
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!