很多项目都用到类似左侧滑动菜单的效果,比如facebook,evernote,VLC for android等等,这很酷
源代码可以从GitHub的https://github.com/jfeinstein10/slidingmenu上下载。
移植过程中会用到Actionbarsherlock这个项目,去http://actionbarsherlock.com/download.html下载。(两个下的都是最新版本)
步骤:
1.将下载的Actionbarssherlock中/library下的文件解压到workspace(你的项目目录),改项目名称为Actionbarssherlock,从eclipse中操作new->project->Android Project from Existing Code将项目添加进去,target改为api14以上。
2.将下载的slidingmenu中/library解压到workspace(你的项目目录),改名SlidingMenu,import该项目,右键->properties->android->api14以上。或者打开project.properties:target=Google Inc.:Google APIs:14或更高。
3.这样SlidingMenu就可以用在自己项目中了。让我们来运行例子。解压slidingmenu中/example。import该项目,设置api14或更高,并add你的SlidingMenu。运行看看效果。2.1以上的系统都可以运行。
虽然是开源项目,但使用过程中还是可能会出现各种问题:
一、修复SlidingMenu library project里出现的错误
二、修复example project里出现的错误
然后,将下面这个父类:
换成Actionbarsherlock里的另外一个父类:
如果错误还是会出现,就clean项目并重启eclipse. 没错误以后运行出下面效果: