Git开源项目SlidingMenu移植问题

在Csdn上,看到介绍的开源项目http://www.csdn.net/article/2013-05-03/2815127-Android-open-source-projects,中的第三个项目:SlidingMenu,很多App都加了这种菜单形式,所以也想研究一下。

其项目Git地址:https://github.com/jfeinstein10/slidingmenu

把项目同步到本地以后,使用Eclipse导入,发现会出错,打开项目的Properties选项:


发现其所依赖的ABS库出错,ABS究竟是什么呢?

原来项目中还依赖Actionbarsherlock这个库,可以在http://actionbarsherlock.com/download.html获取,导入到eclipse里,我命名比较懒,直接命名为library2,

导入library2之前:

导入后出现以下情况:


错误变成了缺少android-support-v4包支持。

后来发现是因为,library类库中和Actionbarsherlock库中都依赖android-support-v4库,可能是因为版本不一,引发冲突,把Actionbarsherlock源码中libs中android-support-v4删除,然后拷贝library中的android-support-v4到Actionbarsherlock中即可。

这个时候发现,可能还有以下错误:

The method getSupportActionBar() is undefined for the type BaseActivity
The method getSupportMenuInflater() is undefined for the type BaseActivity
The method onCreateOptionsMenu(Menu) of type BaseActivity must override or implement a supertype method
The method onOptionsItemSelected(MenuItem) in the type Activity is not applicable for the arguments
The method onOptionsItemSelected(MenuItem) of type BaseActivity must override or implement a supertype method
The method onOptionsItemSelected(MenuItem) of type ResponsiveUIActivity must override or implement a supertype method

修改方法为:打开SlidingMenu library project里SlidingFragmentActivity这个类并在声明前添加以下代码:

import com.actionbarsherlock.app.SherlockFragmentActivity; 

然后,将下面FragmentActivity父类:

public class SlidingFragmentActivity extends FragmentActivity implements SlidingActivityBase {  

替换为:Actionbarsherlock库里的另外一个父类:

public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {  

这里 SlidingMenu library需要依赖Actionbarsherlock,加上即可,如果还有错误,clean下。


PS:

有可能遇到以下错误:

ACTION_POINTER_INDEX_MASK cannot be resolved android.
HONEYCOMB cannot be resolved or is not a field
LAYER_TYPE_HARDWARE cannot be resolved or is not a field
LAYER_TYPE_NONE cannot be resolved or is not a field
MATCH_PARENT cannot be resolved or is not a field
The method getLayerType() is undefined for the type View
The method setLayerType(int, null) is undefined for the type View

修改方法:manifest里面的min sdk version 改为你当前用到的sdk版本7以上。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值