Android异常:requestFeature() must be called before adding content产生原因

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

今天根据教程写了一个例子,就是调用android中的android.hardware.Camera来完成拍照功能,但是遇到这么一个异常。

setContentView(R.layout.main);
requestWindowFeature(Window.FEATURE_NO_TITLE); 

 

解决方法如下:顺序换一下

requestWindowFeature(Window.FEATURE_NO_TITLE); 

setContentView(R.layout.main);

 

你可能感兴趣的:(Android)