网上的各种解决方案已经不少了,但是不适合于我的,谷歌一种新的解决方案

  

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

getActionBar()空指针异常的更多相关文章

  1. Android getActionBar()报空指针异常

    1. 加载完视图后,再去获取: 写在setContentView()后面. 2.sdk版本: Actionbar的主题在3.0以后才有,使用的时候要确保,最低的版本不能小于3.0. <uses- ...

  2. getActionBar()为null的解决方法总结(引用他人)

    最近在看android actionBar的使用,环境为AndroidStudio,建一个简单的工程,功能为:两个按钮,一个单击用于显示actionbar,一个用于隐藏actionbar.默认acti ...

  3. 【Android】getActionBar()为null的解决方法总结

    前言 在使用 ActionBar的时候,有时候会爆出空指针异常,这是由于应用没有获取到 ActionBar 导致的,而导致应用没有获取到 ActionBar 的原因比較多.所以我们以下就来总结一下 A ...

  4. FragmentPagerAdapter加载fragment并使用setUserVisibleHint()处理预加载时遇到的坑,给textview赋值时出现的空指针异常

    FragmentPagerAdapter加载fragment并使用setUserVisibleHint()处理预加载时,给textview赋值时出现的空指针异常 public class BaseFr ...

  5. java空指针异常:java.lang.NullPointException

    一.什么是java空指针异常 我们都知道java是没有指针的,这里说的"java指针"指的就是java的引用,我们不在这里讨论叫指针究竟合不合适,而只是针对这个异常本身进行分析.空 ...

  6. ListView.setAdapter(adapter);空指针异常的解决的总结

    报空指针异常一般的情况: 1,没有找到布局文件的ID  检验是不是id重复或者写错了 2.控件没有实例化 3.没有找到布局文件的id,要看看是不是加载了布局了,必须加载了对应的布局才能找到对应布局下的 ...

  7. 没有R.java问题找不到getActionBar()方法

    android项目,可是项目中没有重要的R.java,并且报错,说是找不到getActionBar()方法,上网寻找原因,终于寻得解决方法:    1.解决项目中没有R.java问题.在Eclipse ...

  8. Myeclipse下JSP打开报空指针异常解决方法。

    Myeclipse下JSP打开报空指针异常解决方法 一.运行JSP文件就出错 静态的JSP页面访问时候正常,只要是牵涉到数据库的页面就出错,出错见下图. 出现这种情况让我调试了一天,各种断点,各种改代 ...

  9. java空指针异常 for循环时,使用了值为null的变量

    错误代码: for(Map<String,Object> videoItemMap:learnVideoList){ String videoStuId=MapUtils.getStrin ...

随机推荐

  1. JSP基础之 C标签中的 varStatues属性

    变量状态参数,该属性有5个常用值count 表示当前遍历集合的元素个数index 表示当前遍历到集合的第几个元素current 表示当前的集合元素first 表示集合的第一个元素last 表示集合的最 ...

  2. A - Next_permutation

    首先介绍一下next_permutation函数的用途! 按照STL文档的描述,next_permutation函数将按字母表顺序生成给定序列的下一个较大的排列,直到整个序列为降序为止. prev_p ...

  3. 配置nginx静态资源路径

    1.修改nginx.conf文件 server节点下location节点的 root目录修改 location / { root html; index index.html index.htm; } ...

  4. PC远程调试移动设备(转载)

    我们在移动端进行前端开发时,会遇到一个让人头痛但不得不面对的问题--调试. 在 PC 机器上,我们有功能强大的 Chrome DevTools.Firebug,即便是老版本的 IE ,我们也可以安装微 ...

  5. 菜鸟的jQuery源码学习笔记(二)

    jQuery对象是使用构造函数和原型模式相结合的方式创建的.现在来看看jQuery的原型对象jQuery.prototype: jQuery.fn = jQuery.prototype = { //成 ...

  6. VS2003转VS2010 fatal error C1189: #error

    我自己的mfc的demo要转换编译环境出现以下编译错误: VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT ...

  7. UVA 1599 Ideal Path (HDU 3760)

    两次bfs: 第一次bfs逆向搜索,得到每个点到终点的最短距离,找出最短路:第二次bfs根据最短距离可以选择满足条件的最短路. 注意!碰到这种很大数据量的题目一定要记得用scanf,printf 输入 ...

  8. QListWidget与QTableWidget的使用以及样式设置

    QListWidget和QTableWidget的使用和属性,QTableWidget和QListWidget样式表的设置,滚动条的样式设置 一.QListWidget的使用 //一.QListWid ...

  9. haproxy hdr和path

    path : string This extracts the request's URL path, which starts at the first slash and ends before ...

  10. linux之SQL语句简明教程---IN

    在 SQL 中,在两个情况下会用到 IN 这个指令:这一页将介绍其中之一 -- 与 WHERE 有关的那一个情况.在这个用法下,我们事先已知道至少一个我们需要的值,而我们将这些知道的值都放入IN 这个 ...