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