很多项目都用到类似左侧滑动菜单的效果,比如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里出现的错误
-
Console error:Unable to resolve target ‘Google Inc.:Google APIs:16.
Fix:进入Properties检查Target
sdk是否选择了Google APIs.
-
List of errors: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
Fix:将manifest里面的min
sdk version 改为你当前用到的sdk版本,7以上.
二、修复example
project里出现的错误
-
Console error:Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are identical (check is based
on SHA-1 only at this time). Jar mismatch! Fix your dependencies
Fix:这是由于jar包版本不一致导致的,检查SlidingMenu和Actionbarsherlock中的\libs文件夹里的哪个android-support-v4.jar版本比较新,用新的替换掉其中的老版本.
如果错误还是会出现,就clean项目并重启eclipse.
-
List of errors: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
Fix:打开SlidingMenu
library project里SlidingFragmentActivity这个类并在声明前添加以下代码:
import com.actionbarsherlock.app.SherlockFragmentActivity;
然后,将下面这个父类:
public class SlidingFragmentActivity extends FragmentActivity implements SlidingActivityBase {
换成Actionbarsherlock里的另外一个父类:
public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {
如果错误还是会出现,就clean项目并重启eclipse.
没错误以后运行出下面效果:
分享到:
相关推荐
android系统开发(四)-触摸屏tslib移植(内核)和原理分析 32 android系统开发(五)-tslib移植 47 Ubuntu下svn安装和使用 50 android系统开发(七)-背光模块 56 android系统开发(八)-SDCARD 61 android系统开发(九)-Audio...
OpenSSH移植到android系统externel步骤
FFMPEG 移植到android
android系统成功移植openssh的步骤
文档记录了ntfs-3g-2013移植到android的详细过程
将本地PC游戏轻松移植到Android的秘技, jni, ndk
介绍 不同硬件平台上移植Android的Camera系统
可以移植到android平台实现NTFS文件系统挂载读写
《tensorflow训练好模型移植到android》教程,共66页pdf格式文档(幻灯片形式),讲解清楚,能很快实现。涉及两个例子,第一个是将Tensor flow的实例编译成APK,安装运行到Android客户端,立即可以使用;第二个是...
移植到 android 下的 ntfs-3g
自己搜集整理一份J2ME游戏移植Android文档以及一个实现J2ME接口的一个游戏引擎
7.4 移植Android专用驱动和组件188 7.5 omap的设备驱动190 第8章 显示系统驱动应用195 8.1 显示系统介绍195 8.1.1 Android的版本195 8.1.2 不同版本的显示系统195 8.2 移植和调试前的准备196 8.2.1 ...
将Cocos2dx从win32移植到android平台 不用cygwin 只要简单的几步就可轻松搞定
如何XBMC 代码编译成android程序,详细步骤
Android系统移植;Android系统移植Android系统移植
移植Android到mini2440开发板
最近一段时间,在android上想用c++处理xml数据,在网上找了半天资料,大多数教程都是在编译android系统的时候顺便把libxml2和libiconv源码放到系统指定路径下编译出来。可是没干过这样的事,也不想这么做。最后还是...
将ffpeg移植到android平台下,将官网下载的ffmpeg移植到android平台下,用ndk编译出可以在android平台JNI调用的so!
NXP-PN5XX Android 驱动移植官方文档,内有详细步骤。