引起:android.util.AndroidRuntimeException:在添加内容之前必须调用requestFeature()
这是我的代码,
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_SWIPE_TO_DISMISS);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}}
答案 0 :(得分:4)
requestFeature() must be called before adding content
好吧,只需执行错误消息告诉您的内容。
请勿在requestFeature()之前调用setContentView()。
注意:
如评论中所述,对于ActionBarSherlock和AppCompat库,在super.onCreate()
之前调用requestFeature()是必要的。