Java – Android fragment ‘requestFeature must be called’

Android fragment ‘requestFeature must be called’… here is a solution to the problem.

Android fragment ‘requestFeature must be called’

I’m having trouble trying to use “requestFeature” in my FRAGMENT. My code is below, I’m trying to set the action bar to override.

    @Override
public void onCreate(Bundle savedInstanceState) {
    getActivity().requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    super.onCreate(savedInstanceState);

I don’t want to

use themes because I don’t want to affect the app in general, and this fragment in particular.

Solution

In the onCreate() method of an activity, you must call requestWindowFeature() before setContentView(). This activity is the activity to which your fragment belongs.

Related Problems and Solutions