使用AppCompat Library进行ActionBar支持

Jor*_*dez 3 java android android-appcompat android-actionbar android-actionbar-compat

我需要在Android 2.x中实现操作栏我已经尝试过这篇文章并设置了这篇官方文章中提到的支持库.

以下是我使用appcompat支持库实现ActionBar所遵循的步骤:

首先,我使用以下配置创建项目(我不创建图标和默认活动):

最低要求SDK: API 10:Android 2.3.3(Gingerbread)
目标SDK: API 19:Android 4.4
编译: API 10:Android 2.3.3(Gingerbread)
主题:无

之后,在Project properties => Android => Library中添加了android-support-v7-appcompat库项目.

在此之后,我在使用appcompat库的项目中得到了128个这样的错误.所有这些都与Holo主题有关:

[2013-12-06 13:24:24 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:24: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.  
Run Code Online (Sandbox Code Playgroud)

请注意,错误仅发生在appcompat库项目中的values-v14values-v11文件夹中.以下是我得到的两个错误示例:

[2013-12-06 13:24:24 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:100: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Subtitle.Inverse'.  
[2013-12-06 13:24:24 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v11\styles_base.xml:26: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ProgressBar.Horizontal'.  
Run Code Online (Sandbox Code Playgroud)

此外,与Holo主题无关的错误很少:

[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:225: error: Error: No resource found that matches the given name: attr 'android:dividerPadding'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\styles_base.xml:224: error: Error: No resource found that matches the given name: attr 'android:showDividers'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v11\themes_base.xml:33: error: Error: No resource found that matches the given name: attr 'android:windowActionBar'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v11\themes_base.xml:44: error: Error: No resource found that matches the given name: attr 'android:windowActionBar'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:41: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:67: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.  
[2013-12-06 13:24:38 - UsingSupportActionBar] C:\dev\Java\android\adt-bundle-windows-x86_64\sdk\extras\android\support\v7\appcompat\res\values-v14\themes_base.xml:94: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.  
Run Code Online (Sandbox Code Playgroud)

有没有人有同样的问题?

Jul*_*xen 15

将"Compile with"设置为API级别19 - 当您使用SDK级别10编译应用程序时,编译器不知道错误日志中显示的元素.