2

I know this question is already been asked on stack but i tried all the solutions but of no use.Still i'm getting the same below error

Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

below is code-

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        **requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);**  
        setContentView(R.layout.info);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
     }

I tried many links like given below- https://stackoverflow.com/search?q=requestFeature%28%29+must+be+called+before+adding+content

is there any solution???

Community
  • 1
  • 1
yuva ツ
  • 3,707
  • 9
  • 50
  • 78

2 Answers2

3

try this

@Override
    protected void onCreate(Bundle savedInstanceState) {

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info);

     }
Hardik
  • 17,179
  • 2
  • 35
  • 40
1

Have you tried this..

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);  
    super.onCreate(savedInstanceState);   
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);     
    setContentView(R.layout.info);        
 }
Hariharan
  • 24,741
  • 6
  • 50
  • 54