Android requestWindowFeature崩溃
2016-05-18 17:30
531 查看
之前代码如下:
}
运行后提示: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.down.musicdemo/
com.example.down.musicdemo.PlayerActivity}: android.util.AndroidRuntimeException: requestFeature() musts be called before adding content
最终发现继承的是ActionBarActivity 而不是 Activity;
class PlayerActivity extends ActionBarActivity {}
所以这个时候的写法应该是:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
public class PlayerActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_player); }
}
运行后提示: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.down.musicdemo/
com.example.down.musicdemo.PlayerActivity}: android.util.AndroidRuntimeException: requestFeature() musts be called before adding content
最终发现继承的是ActionBarActivity 而不是 Activity;
class PlayerActivity extends ActionBarActivity {}
所以这个时候的写法应该是:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
相关文章推荐
- 【Arduino官方教程第一辑】示例程序 4-8 串口双向调用 (握手连接)
- 关于mysql的java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\xBD\xF0\x9F…'问题
- 115. Distinct Subsequences
- UGUI-初识
- iOS UIAlertController使用方法如何使用
- angular+ui-router+requirejs整合demo
- [解决方案]MySql提示:The server quit without updating PID file(…)失败
- UiAutomator——如何保存测试异常现场@Before @After
- iOS UITabBarController中设置字体颜色及大小
- MXE (M cross environment) Requirements
- Longest Increasing Subsequence
- 关于UIView布局的总结
- leetcode 232. Implement Queue using Stacks
- UIUITableView仿淘宝的两列式cell显示
- UE4之GamePlay
- iOS学习之—— UIDevice、NSBundle、NSLocale
- iOS 视图UIview属性介绍 以及视图层次方法
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- 使用UIBezierPath和CAShapeLayer画各种图形
- 10.UIImageView