android – 切换到API21 AppCompat后缺少ActionBar

android – 切换到API21 AppCompat后缺少ActionBar,第1张

概述在我将AppCompat库从API 19更新为API 21时,在为Big Nerd Ranch的犯罪意图项目工作时,我丢失了ActionBar.我试过改变主题,但我找不到获取ActionBar的方法. 完整的源代码可用于here. AndroidManifest.xml中 <?xml version="1.0" encoding="utf-8"?><manifest xmlns:android= 在我将AppCompat库从API 19更新为API 21时,在为Big Nerd Ranch的犯罪意图项目工作时,我丢失了Actionbar.我试过改变主题,但我找不到获取Actionbar的方法.

完整的源代码可用于here.

AndroIDManifest.xml中

<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID"    package="com.sudhirkhanger.app.criminalintent" >    <application        androID:allowBackup="true"        androID:icon="@drawable/ic_launcher"        androID:label="@string/app_name"        androID:theme="@style/Apptheme" >        <activity androID:name=".CrimeListActivity" >            <intent-filter>                <action androID:name="androID.intent.action.MAIN" />                <category androID:name="androID.intent.category.LAUNCHER" />            </intent-filter>        </activity>        <activity            androID:name=".CrimePagerActivity"            androID:label="@string/app_name" >        </activity>    </application></manifest>

style.xml

<resources>    <!-- Base application theme. -->    <style name="Apptheme" parent="theme.AppCompat.light.DarkActionbar">        <!-- Customize your theme here. -->    </style></resources>

谢谢.

解决方法 要使用appcompat-v7,您必须从ActionBaractivity继承. CrimeListActivity继承自SingleFragmentActivity,而SingleFragmentActivity继承自FragmentActivity,而不是ActionBaractivity. 总结

以上是内存溢出为你收集整理的android – 切换到API21 AppCompat后缺少ActionBar全部内容,希望文章能够帮你解决android – 切换到API21 AppCompat后缺少ActionBar所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1130108.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存