添加“jfeinstein10/SlidingMenu"的确切程序;在安卓项目中 [英] Exact procedure to add "jfeinstein10 / SlidingMenu" in android project
问题描述
我对android完全陌生,我正在尝试实现具有ListView的滑动菜单滑动手势
,通过一些搜索我发现https://github.com/jfeinstein10/SlidingMenu正是我想要的,
I am totally new to android, i am trying to implement Sliding Menu having ListView with
Swipe Gesture
, by some searching i found that https://github.com/jfeinstein10/SlidingMenu
is exactly what i want,
有很多与此相关的问题指导如何将这个库与项目集成,但没有一个适合像我这样的新手.github 上给出的过程也不详细,我只知道如何添加 .jar 文件,但是这个 .zip 和其他东西对我来说是全新的
There are many questions related to this which are guiding how integrate this library with project, but none of them are for new person like me. also procedure given on github is not detailed, all i know is how to add .jar file but this .zip and other things are totally new for me
这是我迄今为止所做的;
This is what i have done till yet;
- 从上面的链接下载 zip
- 将该链接提取到文件夹
- 在 Eclipse File->import->现有项目到工作区..
现在它向我显示包 library.src.com.slidingmenu.lib.app
例如
声明的包com.slidingmenu.lib.app"与预期的包library.src.com.slidingmenu.lib.app"不匹配
现在我不知道该怎么办...
now i don't know what to do...
请有人指导我如何在项目中集成和使用这个库的正确详细过程.
please somebody guide me with proper detailed procedure of how to integrate and use this library in project.
谢谢!
推荐答案
嗯,用了 3 天的时间来解决同样的问题,我找到了解决这个问题的确切程序.github 上的指南当然不适合像我们这样的入门级人,也没有这样的用于此的分步教程",因此需要时间.
Well, spending 3 days with same problem I found the exact procedure for this thing. The guide on github is of-course not for entry level guys like us, also there is no such a "step-by-step tutorial" for this, so it took time.
重要:我没有包含Sherlock ActionBar
"库,因为我想保持简单
Important: I didn't include "Sherlock ActionBar
" library, because I want to keep it simple
首先将您的 eclipse 更新到最新的
ADT
或者您可以下载 thisADT Bundle
,并确认在新的ADTBundle
中一切正常.
First up all update your eclipse to latest
ADT
or best way you can download thisADT Bundle
, and confirm that everything is running fine in newADTBundle
.
下载最新的jfeinstein10/SlidingMenu 的zip"来自"gitHub",然后将其提取到任何您想要的位置.解压后里面一定有这些文件和文件夹.
Download latest "zip for jfeinstein10 / SlidingMenu" from "gitHub", And extract it anywhere you want. After extraction it must have these files and folders inside.
- 现在打开你的eclipse
File ->导入 ->安卓->现有 Android 代码进入工作区
,浏览到您的文件夹很可能是SlidingMenu-master
",您应该看到以下内容
- Now open your eclipse
File -> Import -> Android -> Existing Android Code Into Workspace
, Browse to your folder most probably "SlidingMenu-master
" and you should see following
点击Finish
,如果eclipse显示一些错误,如Unable to resolve target
,然后通过Right Click on project改变你的目标->属性 ->Android
并检查您的 SDK 具有的任何最新 google API
.
Hit Finish
, If eclipse shows some error like Unable to resolve target
then change your target through Right Click on project -> Properties -> Android
and check any latest google API
your SDK have.
添加
Dependency
,右键点击project ->属性 ->安卓->图书馆 ->添加 ->SlidingMenuActivity
,并清除两个项目.
Add
Dependency
, by right clicking onproject -> properties -> android -> library -> add -> SlidingMenuActivity
, and clear both projects.
在您的 res -> 中添加名为
并将以下内容放入其中将menu_frame
的新 XML 布局布局Frame Layout
和list view
放入其中.
Add new XML layout named as menu_frame
in your res -> layout
and put following in it
Put Frame Layout
and list view
in it.
同时在您的 mainActivity
XML 文件中添加一个 ListView
.
Also add a ListView
in your mainActivity
XML file.
现在是创建菜单"的时候了,在 setContentView(R.layout.activity_main)
之后的 onCreate()
中编写以下代码.
Now it is time to create "Menu" write following code in your onCreate()
after setContentView(R.layout.activity_main)
.
SlidingMenu menu;
menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidth(5);
menu.setFadeDegree(0.0f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setBehindWidth(200);
menu.setMenu(R.layout.menu_frame);
在显示错误的行按 ctrl+1
并导入 com.slidingmenu.lib.SlidingMenu;
"
运行您的项目,您应该会看到从左侧出现的菜单
Run your project and you should see menu coming out from left side
现在下一个任务是为您的两个 ListViews(即主屏幕和菜单)添加 adapter
和 listener
.
Now the next task is to add adapter
and listener
for both of your ListViews (i.e for Main-screen and Menu).
有关创建菜单时使用的功能的信息,您可以参考图书馆提供的示例应用程序或谷歌它们,有很多可用信息.
For information about function used while creating Menu you can refer to example apps provided with library or google them, there is lot of info available.
还要感谢Jeremy Feinstein"提供这么棒的图书馆
Also thanks to "Jeremy Feinstein" for such a great library
这篇关于添加“jfeinstein10/SlidingMenu"的确切程序;在安卓项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!