在我更新了Android的SDK 5.0版getActionBar()方法开始返回null导致我的应用程序崩溃上推出。我无言以对,以什么导致这一点,任何现有的#1线并没有帮助。
After I updated the Android SDK to version 5.0 the getActionBar() method started to return null causing my app to crash on launch. I am clueless to what's causing this and any existing Stackoverflow threads didn't help.
下面是我的清单:
<application
android:name="App"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/ActionBarTheme" >
styles.xml:
styles.xml:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"></style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme"></style>
<style name="ListItemPadding">
<item name="android:paddingTop">8dp</item>
<item name="android:paddingRight">5dp</item>
<item name="android:paddingBottom">8dp</item>
<item name="android:paddingLeft">5dp</item>
</style>
的themes.xml:
themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- the theme applied to the application or activity -->
<style name="ActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="android:actionOverflowButtonStyle">@style/OverflowButton</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/ActionBar</item>
<item name="actionOverflowButtonStyle">@style/OverflowButton</item>
</style>
<style name="OverflowButton" parent="android:style/Widget.Holo.ActionButton.Overflow">
<item name="android:src">@drawable/menu</item>
</style>
<!-- ActionBar styles -->
<style name="ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/main</item>
<!-- Support library compatibility -->
<item name="background">@color/main</item>
</style>
</resources>
和我的摇篮依赖关系:
dependencies {
compile 'com.github.jenzz.undobar:library:1.1:api8Release@aar'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.loopj.android:android-async-http:1.4.5'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.google.android.gms:play-services:6.1.+'
}
任何帮助是极大AP preciated!
Any help is greatly appreciated!
使用 getSupportActionBar()
当您使用 ActionBarActivity
和 appcompat-V7
,因为你似乎是在这里做什么。
Use getSupportActionBar()
when you are using ActionBarActivity
and appcompat-v7
, as you appear to be doing here.
上一篇:Android的动作条的兼容性:MenuItem.setActionView(查看)兼容性、动作、Android、MenuItem
下一篇:安卓5.1.1及以上 - getRunningAppProcesses()只返回我的应用程序包我的、程序包、getRunningAppProcesses