关于“requestWindowFeature”的错误

时间:2016-04-26 05:30:25

标签: android android-layout android-intent

package com.act;

import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity{
    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        setContentView(R.layout.main);
    }
}

第二行“Window”出现错误。如果有人是中国人,请用中文回答我,因为我的英语不好。

3 个答案:

答案 0 :(得分:0)

在您的活动中打开AndroidManifest.xml文件集主题

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

    this.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);

答案 1 :(得分:0)

在调用setContentView()之前,您是否尝试过调用requestWindowFeature()?

根据这篇文章,这是必要的。

Window.requestFeature()的文档:

Enable extended screen features. This must be called before setContentView(). May be called as many times as desired as long as it is before setContentView().

答案 2 :(得分:0)

@Override  
protected void onCreate(Bundle savedInstanceState) {  
super.onCreate(savedInstanceState);  

requestWindowFeature(Window.FEATURE_NO_TITLE);  
//code that displays the content in full screen mode  
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
            WindowManager.LayoutParams.FLAG_FULLSCREEN);//int flag, int mask  

setContentView(R.layout.activity_main);  

}
 如果有帮助让我知道,请尝试此操作