最近在学习第一行代码这本书,里面的关于activity生命周期有一段例子,但是我自己用mac上装的as运行一直出问题,看log的话就是android.util.AndroidRuntimeException: requestFeature() must be called before adding content这个错误,从网上找了半天,终于找到了解决办法,虽然没有太明白原理,但是在这里做个分享吧。

这个是修改之后的代码

 protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_layout);
}

本来requestWindowFeature这个方法是在第二句的,但是并没有跟报错的内容相符合,但是确实把这个语句放在最前面就可以运行了,有知道为什么的大神可以帮我解答一下,谢谢。

android.util.AndroidRuntimeException: requestFeature() must be called before adding content解决办法的更多相关文章

  1. android.util.AndroidRuntimeException: requestFeature() must be called before adding content 错误解决方法

    Activity全屏,网上的代码如下:protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance ...

  2. Android Exception 9(requestFeature() must be called before adding content)

    08-05 17:36:12.799: W/System.err(10378): java.lang.reflect.InvocationTargetException08-05 17:36:12.7 ...

  3. .AndroidRuntimeException: requestFeature() must be called before adding content

    有以下几种情况: 1. setContentView(R.layout.activity_list); requestWindowFeature(Window.FEATURE_NO_TITLE); 修 ...

  4. requestFeature() must be called before adding content产生原因和解决办法

    03-24 01:07:31.504 2957-2957/com.santai.jrj E/AndroidRuntime: FATAL EXCEPTION: main Process: com.san ...

  5. Android真机调试 Android.Util.AndroidRuntimeException: You cannot combine custom titles with other title features

    参考连接:http://blog.csdn.net/scyatcs/article/details/9003285 Android.Util.AndroidRuntimeException: You ...

  6. Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity

    Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity ...

  7. android.util.AndroidRuntimeException Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? com.uethinking.microvideo.manag

    记录学习,网络摘抄 碰到这个异常其实这个上面说的很清楚,加个flag 从一个Activity中要通过intent调出另一个Activity的话,需要使用 FLAG_ACTIVITY_NEW_TASK ...

  8. Android开发中遇到的requestFeature() must be called before adding content异常

    缘起 上一篇博文中讲到了几种实现全屏显示Activity内容的方法.然而实际在实现中发现了一些问题,在本篇博文中进行总结下.首先交代一下开发环境,本人使用的是Android Studio 1.5.1, ...

  9. requestFeature() must be called before adding content

    错误:requestFeature() must be called before adding content 原因: Android去掉标题栏点菜单键程序崩溃 在安卓以前的版本中,我们会使用以下两 ...

随机推荐

  1. Android开发视频学习(2)

    S02E05_Android当中的线程 Worker Thread不允许操作UI,只能在Main Thread操作UI S02E06_Handler(一) Handler,Looper,Message ...

  2. POJ 2406

    思路:由于题目要求的是最大值,因此从n开始向下查找,第一次出现的满足条件的那个数就是最大的,查找就可以结束,如果查找到1是仍未找到合适的值,则为1,就是说不是任何字符串的次方如abcd #includ ...

  3. PC 端 360 云盘初体验

    首先吐槽一下安装软件,文件名是 360wangpan,安装好后软件名称是"360云盘",好歹得统一下嘛,不然还以为下错了安装文件呢. 一般使用和其他网盘差不多,速度也还行,但还是没 ...

  4. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake

    水题 #include<iostream> #include<string> #include<algorithm> #include<cstdlib> ...

  5. Android 画直线并实现拖动

    自定义View,在onDraw()方法中绘制一条直线,在onTouch()方法中监听手指的移动. public class AroundDragView extends View implements ...

  6. TCA9546A

    The TCA9546A is a 4-channel, bidirectional translating switch for I 2 C buses that supports Standard ...

  7. 输入n个数组,数组长度不等,每个数组取出一个数进行组合,求出所有的组合。

    转载声明:原文转自http://www.cnblogs.com/xiezie/p/5511707.html 昨天晚上,有个朋友找到我,他在用matlab编程,但是遇到一个问题,解决不了. 问题如下: ...

  8. iOS 检测网络切换

      CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center             ...

  9. CF_402B 想法题

    题目链接:http://codeforces.com/problemset/problem/402/B /**算法分析: 题意太大意,positive没注意这个问题 考察等差数列,由An=A1+(n- ...

  10. IIS8之System.ServiceModel.Activation.HttpModule錯誤處理

    在Windows Server 2012 R2上安装一个WCF服务,怎么弄都是报System.ServiceModel.Activation.HttpModule錯誤 经过不懈尝次及查找资料,终于找到 ...