使用动作条compability版本的Andr​​oid 4.0动作、版本、compability、Andr

2023-09-12 02:59:23 作者:人间不值得

我跟着code在动作条compability版本

当我使用code的API级别10或小于它,它显示了一个动作条,但是当我使用它的API级别11或更高版本,它不显示标识图标和行动项目。

When I use the code for API level 10 or less than it, it shows a ActionBar, but when I use it for API level 11 or greater, It does not show logo icon and Action items.

我检查了班,我明白了:

I checked the classes and I understood:

ActionBarHelperBase:API等级10以下

ActionBarHelperBase : API level 10 or less.

ActionBarHelperHoneycomb:API级别11或更高。

ActionBarHelperHoneycomb : API level 11 or greater.

ActionBarHelperICS:API级别14或更高

ActionBarHelperICS : API level 14 or greater.

什么是固定的动作条的Andr​​oid版本3.0或更高版本的最好方法是什么?特别的Andr​​oid 4.0

What is the best way to fix the ActionBar for Android Version 3.0 or greater? Specially Android 4.0

推荐答案

这个问题是在清单文件。我应该删除机器人:主题=@风格/ Theme.ThemeCompabilityVersion 从清单文件

The problem was in the Manifest file. I should remove android:theme="@style/Theme.ThemeCompabilityVersion from the Manifest file.

然后,我需要检查的OnCreate在code版本()之类方法:

Then I need to check the version in the code in OnCreate() method like:

private void setTheme() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) 
        setTheme(R.style.ThemeCompabilityVersion);
    else 
        setTheme(R.style.AppTheme);         
}