ActionBar in Android Maven Project using Android Support Library v7

て烟熏妆下的殇ゞ 提交于 2019-11-30 20:32:59

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/22573346/actionbar-in-android-maven-project-using-android-support-library-v7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!