ActionBar的使用——低版本兼容
16lz
2022-05-22
ActionBar是android 3.0之后才出的,也就是API 11及以上才有。
在minSdkVersion中填7的话,就会报错。
有一个办法可以解决。在使用ActionBar的activity属性上加android:theme="@android :style/Theme.Holo"就不会报错了。
示例AndroidManifest.xml文件如下:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.actionbartest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.actionbartest.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Holo" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
更多相关文章
- Android中RelativeLayout各个属性的含义
- android animation
- fitsSystemWindows的理解与沉浸式状态栏实现
- Android基础知识之Manifest文件的组织结构
- Android七大布局
- Android属性系统
- listview使用小技巧
- EditText android:windowSoftInputMode 属性之旅
- Mapbox Android学习笔记(1)简介