简体   繁体   English

使用Android支持库v7在Android Maven项目中的ActionBar

[英]ActionBar in Android Maven Project using Android Support Library v7

I have a Android Maven project and am having difficulties to maintain compatibility using ActionBar. 我有一个Android Maven项目,并且很难使用ActionBar维护兼容性。

Before I was using ActionBarSherlock , but I saw that Google released the v7 support library would have the same goal. 在我使用ActionBarSherlock之前,我看到谷歌发布的v7支持库将有相同的目标。 I decided to remove the dependence of ActionBarSherlock and use v7. 我决定删除ActionBarSherlock的依赖并使用v7。 I've tried several ways: 我尝试了几种方法:

  • 1 - Import the folder "android-sdk\\extras\\android\\support\\v7\\appcompat" as a "Existing Android Code into Workspace" on Eclipse IDE and registered him as Library. 1 - 在Eclipse IDE上将文件夹“android-sdk \\ extras \\ android \\ support \\ v7 \\ appcompat”作为“现有Android代码导入Workspace”并将其注册为Library。 But the project stopped identifying the classes generated by the framework AndroidAnnotations. 但该项目停止识别框架AndroidAnnotations生成的类。 For example LoginActivity_ 例如LoginActivity_
  • 2 - Adding maven appcompat-v7 dependency using the repository showing this question . 2 - 使用显示此问题的存储库添加maven appcompat-v7依赖项。 But I could not make the project compile, even trying different configurations of dependence. 但我无法使项目编译,甚至尝试不同的依赖配置。

Has anyone set up an android project with library support v7 using Maven? 有没有人使用Maven设置一个带有库支持v7的android项目? Could you help me please? 请问你能帮帮我吗?

Implement ActionBar in 2.2 device and other Functionlity like ViewPager,Framgmet Tag in 2.2 then there is two way using sherlockActionbar and AppCompat 在2.2设备中实现ActionBar和2.2中的ViewPager,Framgmet Tag等其他功能,然后使用sherlockActionbar和AppCompat两种方式

Sherlock is and third party library while AppCompat is Android library. Sherlock是第三方库,而AppCompat是Android库。
step to use AppCompact in project 步骤在项目中使用AppCompact

just update android skd-> extra-> Android support library 只需更新android skd-> extra-> Android支持库
Then goto you sdk in your system-> Androidsdk\\extras\\android\\support\\v7 find appcompat source code. 然后转到你的系统中的sdk-> Androidsdk \\ extras \\ android \\ support \\ v7找到appcompat源代码。 Import this appcompact in you eclipse. 在你的eclipse中导入这个appcompact。
Create you project and select appcompact library from property->android-> Library. 创建项目并从property-> android-> Library中选择appcompact库。
open you manifeast file and change theme **android:theme="@style/Theme.AppCompat.Light**" Then extend your activity with ActionBarActivity if you cannot found it then pls manualy import ` 打开你的表现文件并更改主题**android:theme="@style/Theme.AppCompat.Light**"然后用ActionBarActivity扩展你的活动,如果你找不到它然后请manualy **android:theme="@style/Theme.AppCompat.Light**"

 import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBar.Tab;
 import android.support.v7.app.ActionBarActivity;`

Then Add below code to activity 然后将以下代码添加到活动中

final ActionBar actionBar = getSupportActionBar();
actionBar.setHomeButtonEnabled(false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM