getActionBar()空指针异常
网上的各种解决方案已经不少了,但是不适合于我的,谷歌一种新的解决方案
you can directly specify it in manifest file
1
2
3
4
|
< application android:icon = "@drawable/app_icon" android:label = "@string/app_name" android:theme = "@android:style/Theme.Holo.Light" > |
There are 3 themes available Theme.Holo.Light/Theme.Holo.Dark/Theme.Holo.Light.DarkActionBar.
Theme.Holo.Light requires API level >=11 while Theme.Holo.Dark/Theme.Holo.Light.DarkActionBar requires API level >= 14
If you want to change themes according to API level, you can specify a base appTheme, and override it in style files
1
2
3
4
|
< application android:icon = "@drawable/app_icon" android:label = "@string/app_name" android:theme = "@style/appTheme" > |
values/styles.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
< resources > <!-- Base application theme, dependent on API level. --> < style name = "AppBaseTheme" parent = "android:Theme.Light" > </ style > < style name = "AppTheme" parent = "AppBaseTheme" > </ style > </ resources > |
values-v14/styles.xml
1
2
3
4
5
6
7
8
9
10
11
|
< resources > <!-- Base application theme for API 14+. This theme completely replaces AppBaseTheme --> < style name = "AppBaseTheme" parent = "android:Theme.Holo.Light.DarkActionBar" > </ style > </ resources > |
If you want a consistent theme while maintain compatibility with lower API levels, look at what these people are doing op
The second solution is to request ActionBar feature manually instead making the theme do it for you. I am too lazy to try it myself. This link explain it pretty well. op
最新文章
- edit
- python logging bydate
- windows下CMake使用图文手册 Part 3
- Python自动化 【第七篇】:Python基础-面向对象高级语法、异常处理、Scoket开发基础
- sqlserver2008 如何定时清理索引碎片
- 自己总结python用xlrd\xlwt读写excel
- 水dp第二天(背包有关)
- APACHE服务器出现No input file specified.的完美解决方案
- java安全——BASE64
- Tomcat增加Context配置不带项目名访问导致启动的时候项目加载两次
- vue中nextTick和$nextTick的差别
- [SDOI2009]HH的项链 BZOJ1878
- HDU1560 DNA sequence(IDA*)题解
- MYSQL语句:创建、授权、查询、修改、统计分析等 一 用户的创建、权限设置、删除等
- 源码|ThreadLocal的实现原理
- ASP.NET 获得当前网页名字
- Android 全局异常处理(一)
- building for production...Killed
- 请求URL中有body怎么使用jmeter进行接口测试
- 解析gtest框架运行机制
热门文章
- 定时排程刷新微信access-token
- ORACLE行转列(行转1列,行转多列)
- eclipse项目提交到git
- [Effective Modern C++] Item 3. Understand decltype - 了解decltype
- bluestacks安装安卓引擎时出现2502 2503错误的解决办法
- 2015.4.16-SQL-内连接与外连接
- Android Fragment(碎片)的使用
- Spring:启动项目时加载数据库数据(总结)
- PLSQL实例(游标)
- mysql 根据规定的数组进行排序