码迷,mamicode.com
首页 > 其他好文 > 详细

requestFeature() must be called before adding content 解决方法

时间:2015-04-06 06:29:32      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:android

今天在做一个app引导界面的时候,想设置成全屏显示,一直报错aused by: android.util.AndroidRuntimeException: 
requestFeature() must be called before adding content,百度了很多都不行后来实在没办法了,Google了一下,终于解决了,由于我用的是Google最新的开发工具,继承的是ActionBarActivity,改成继承Activity 完美解决!!

//supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        //取消标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //取消状态栏
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
         // 写在 super.onCreate(savedInstanceState);this.setContentView(R.layout.activity_main); 之前




public class MainActivity extends Activity {

    private ViewPager mPager;
    private ArrayList<View> mPageViews;
    private MyPagerAdapter mPageAdapter;

    private ViewPager mFramePager;
    private ArrayList<View> mFramePageViews;
    private MyPagerAdapter mFramePageAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        //取消标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //取消状态栏
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
            
        super.onCreate(savedInstanceState);

        this.setContentView(R.layout.activity_main);
        initViewPager();


    }

技术分享



本文出自 “阿乾-在路上” 博客,请务必保留此出处http://xiaocool.blog.51cto.com/1593956/1629170

requestFeature() must be called before adding content 解决方法

标签:android

原文地址:http://xiaocool.blog.51cto.com/1593956/1629170

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!