在Android Maven项目中使用Android支持库v7的ActionBar[英] ActionBar in Android Maven Project using Android Support Library v7

本文是小编为大家收集整理的关于在Android Maven项目中使用Android支持库v7的ActionBar的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我有一个Android Maven项目,并且很难使用ActionBar保持兼容性.

在使用 ActionBarsherlock 之前,我看到Google发布了 v7支持库的目标.我决定删除ActionBarsherlock的依赖性并使用V7.我尝试了几种方法:

  • 1-导入文件夹" Android -SDK \ Extras \ Android \ support \ v7 \ AppCompat"作为"现有的Android代码"在Eclipse IDE上的工作空间中,并将其注册为库.但是该项目停止识别框架AndroidAnnotations生成的类.例如登录_
  • 2-使用存储库添加maven appcompat -v7依赖关系,显示此问题.但是我无法进行项目编译,甚至尝试了不同的依赖配置.

是否有人使用Maven设置了使用Library支持V7的Android项目?你能帮我吗?

推荐答案

在2.2设备中实现ActionBar和其他功能词,例如ViewPager,Framgmet标签,在2.2中,使用SherlockactionBar和AppCompat

有两种方式

sherlock是第三方库,而appcompat是Android库.
在项目中使用AppCompact的步骤



只需更新Android SKD-> Extry-> Android支持库
然后将您的SDK在您的System-> androidsdk \ extras \ android \ android \ android \ support \ v7中找到您的sdk.将此AppCompact导入您的日食.
创建项目并从属性 - > android->库中选择AppCompact库.
打开您的平台文件并更改主题**android:theme="@style/Theme.AppCompat.Light**" 然后使用ActionBarActivity扩展您的活动,如果找不到它,请使用手动导入`

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

然后将以下代码添加到活动

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

本文地址:https://www.itbaoku.cn/post/102532.html

问题描述

I have a Android Maven project and am having difficulties to maintain compatibility using ActionBar.

Before I was using ActionBarSherlock, but I saw that Google released the v7 support library would have the same goal. I decided to remove the dependence of ActionBarSherlock and use 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. But the project stopped identifying the classes generated by the framework AndroidAnnotations. For example LoginActivity_
  • 2 - Adding maven appcompat-v7 dependency using the repository showing this question. 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? 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

Sherlock is and third party library while AppCompat is Android library.
step to use AppCompact in project

just update android skd-> extra-> Android support library
Then goto you sdk in your system-> Androidsdk\extras\android\support\v7 find appcompat source code. Import this appcompact in you eclipse.
Create you project and select appcompact library from property->android-> Library.
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 `

 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);