Getactionbar () NULL pointer exception

Source: Internet
Author: User

There are a lot of solutions online, but not for me, Google a new solution

  

You can directly specify it in manifest file

1234 < application           android:icon = "@drawable/app_icon" &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; android:label = "@string/app_name" &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; android:theme = >

There is 3 themes available Theme.holo.light/theme.holo.dark/theme.holo.light.darkactionbar.

Theme.Holo.Light requires API level >=11 and Theme.holo.dark/theme.holo.light.darkactionbar requires API level > = 14

If you want to the change themes according to API level, you can specify a base apptheme, and override it in style files

1234 <application        android:icon="@drawable/app_icon"        android:label="@string/app_name"        android:theme="@style/appTheme">

Values/styles.xml

1234567891011121314 <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

1234567891011 <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 and maintain compatibility with lower API levels, look at what these people is doing op

The second solution is to request ActionBar feature manually instead making the theme does it for you. I am too lazy to try it myself. This link explain it pretty well. Op

Getactionbar () NULL pointer exception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.