zoukankan      html  css  js  c++  java
  • android exception requestfeature must be called before adding content

    刚才做开发的时候遇到了这样的问题,

    java.lang.RuntimeException:Unable to start activity ComponentInfo

    经常查找原来是添加

    取消标题取消标题的代码的原因

         requestWindowFeature(Window.FEATURE_NO_TITLE);// //取消标题

         setContentView(R.layout.onlinevideo);//Activity样式文件,一定要写在中间
     this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
         WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
         initButton();
         videoView = (VideoView) this.findViewById(R.id.rtsp_player);
         videoView.setOnErrorListener(videoErrorListener);
         videoView.setMediaController(new MediaController(this));

    java.lang.RuntimeException:Unable to start activity ComponentInfo

    这是因为:

    android java的执行顺序有关!目前遇到的这个问题就是因为在系统运行开始的时候就已经调用父类的构造方法,接着调用setContentView方法展示视图界面。R.layout.main是R.java资源类中的一个属性。当你在调用这个方法之后在声明Widget就会报:android.util.AndroidRuntimeException: requestFeature() must be called before adding content

    所以前面的那三句中加载Activity的样式的那句代码一定要写在中间。

  • 相关阅读:
    软件开发规范
    Fail2ban + firewalld 防护doss攻击
    SourceTree&Git部分名词解释
    训子
    一个网络下,手机如何访问本地网址
    tempalte.js的一般用法
    template.js的介绍
    获取URL中的参数
    js判断苹果和安卓端或者wp端
    HTML5与WebGL编程
  • 原文地址:https://www.cnblogs.com/songtzu/p/2837785.html
Copyright © 2011-2022 走看看