首页 热点专区 义务教育 高等教育 出国留学 考研考公

github 上有什么价值的android 源码

发布网友 发布时间:2022-04-25 13:01

我来回答

2个回答

懂视网 时间:2022-05-07 03:26

本来想自己写的, 怎么都觉得没有这篇写的好, 就贴个链接了: http://www.samcoles.co.uk/mobile/android-use-greendroid-to-implement-an-actionbar/ This post covers the basics of setting up a project using the GreenDroid library including pullin


本来想自己写的, 怎么都觉得没有这篇写的好, 就贴个链接了:

http://www.samcoles.co.uk/mobile/android-use-greendroid-to-implement-an-actionbar/


This post covers the basics of setting up a project using the GreenDroid library including pulling it from GitHub and how to use the ActionBar it provides. GreenDroid is a useful UI library for Android developed by Cyril Mottier. You can check out all the features it provides by downloading the GDCatalog app from the Android Market.

The action bar:

is located at the top of the screen to support navigation and highlight important functionalities
replaces the title bar (which is often included into it)
is best used for actions across your app, like search, refresh and compose
can provide a quick link to app home by tapping the app logo
is preferably not contextual, but actions can differ from page to page
Android Patterns

If you don’t have EGit in Eclipse. You’ll need to install it. See here. Begin by opening the “Git Repository Exploring” perspective. Window > Open Perspective. Click the button for “Clone a Git Repository and add the clone to this view” and paste in this to the URI field: https://github.com/cyrilmottier/GreenDroid.git – the rest of the details should be filled in automatically, so hit next and follow the wizard through. It’s likely you won’t need to change anything.


You’ll notice the GreenDroid repository is now available to you. Open out the branches GreenDroid > Working directory, right click the folder ‘GreenDroid’ and select ‘Import Projects’. Follow the dialog through and click finish. Switch back to the Java Perspective and you will now have the GreenDroid project imported. You will likely have a problem with the project’s ‘gen’ folder or R.java. If you do (an exclamation mark or cross next to the project name), delete it and then recreate a new folder called gen, if not, create the folder. I also had to right click the project, Android Tools > Fix Project Properties to get it working as it was targeting a different compiler version to mine.

Next up create your new Android Project, the build target will need to be a minimum of 1.6 to use GreenDroid. Right click on your newly created project, select Properties, then select Android on the left hand side of the dialog. At the bottom of the window you can click “Add..” and you should have the option to select GreenDroid as a library. Click OK.

Change your default Activity to extend GDActivity. Wherever you want to use the GreenDroid ActionBar your class will need to extend GDActivity, GDListActivity or GDTabActivity. You will also need to remember to no longer call setContentView() to set your layout and instead use setActionBarContentView(). The former will crash your Activity. Change these and hit ctrl+shift+o to organise your imports.

public class GreenDroidActionBarExampleActivity extends GDActivity {
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setActionBarContentView(R.layout.main);
 }
}

Next add a new class to your project that extends GDApplication. Override the getHomeActivityClass() method and the getMainApplicationIntent() methods. The former will need to return your main home/launcher activity and the latter will return an Intent to view the relevant website for your app:

public class GDActionBarExampleApplication extends GDApplication {
 
 @Override
 public Class getHomeActivityClass() {
 return GreenDroidActionBarExampleActivity.class;
 }
 
 @Override
 public Intent getMainApplicationIntent() {
 return new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.app_url)));
 }
 
}


You will also need to add the the app_url string to your res/values/strings.xml file:


http://www.samcoles.co.uk

Next update your AndroidManifext.xml to use your new Application class:


Right click your res/values folder and create a new xml values file, call it themes.xml. In here we will specify some app-wide styles for your ActionBar. Ignore the error on the gdActionBarApplicationDrawable and gdActionBarBackground value for now:



 

Again, update the application tag in your AndroidManifest.xml to use this theme:

Back to the error in themes.xml. It is clear that you could just place an image into your drawable folders called application_logo. But we are going to use a StateDrawable xml so that the logo behaves like a button. Create a folder, /res/drawable
 and within here create two new xml files called application_logo.xml and action_bar_background.xml, the latter will be a ShapeDrawable for our ActionBar’s background. In application_logo.xml place your state drawable code that defines the image to use for
 pressed, focused and normal states:



 
 
 
 
 
 
 

and in action_bar_background.xml the ShapeDrawable code. This is just a solid block of colour, but you could specify a gradient or even use an image:


 

 
 
 

Next you will need to place the images you’ve specified in the application_logo.xml StateDrawable into your project. The GDCatalog app uses the dimensions of 205×51 pixels for the hdpi versions and 135×34 for the mdpi version. I haven’t yet needed to experiment with different sizes so mine are the same dimensions, and these suit the ActionBar proportions well. Place these into the relevant res/drawable-hdpi and res/drawable-mdpi folders.

You should now be able to run the project and test it out! It won’t look much but you can tap the logo and it should open the URL specified in your app_url string. Notice also that it changes to your application_logo_alt.png image when touched or selected.

Next we will make the ActionBar a little more useful by adding a button to it that will take us to our application’s info activity. Back in GreenDroidActionBarExampleActivity, simply add an info button by placing this call in your onCreate() method:

addActionBarItem(Type.Info, ACTION_BAR_INFO);

Also add that constant to the top of your class:

private static final int ACTION_BAR_INFO = 0;

Go ahead and run it again. The info button is in! But you’ll notice that nothing happens when you click it.

To enable this button to do something we need to override onHandleActionBarItemClick(). Right click your Activity, source > Override/Implement methods and choose it from the options under GDActivity. You can get the value of the id that was passed in the second parameter of addActionBarItem by calling getItemId() on the item. So create a switch block on this value and start InfoActivity (we’ll create this next) if the info button has been pressed:

@Override
public boolean onHandleActionBarItemClick(ActionBarItem item, int position) {
 switch(item.getItemId()) {
 case ACTION_BAR_INFO:
 startActivity(new Intent(this, InfoActivity.class));
 break;
 default:
 return super.onHandleActionBarItemClick(item, position);
 }
 return true;
}

Create the new class InfoActivity that extends GDActivity, and don’t forget to add it to your manifest.


In your onCreate() method of InfoActivity set the title to be displayed in the Action Bar:

@Override
public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setActionBarContentView(R.layout.main);
 setTitle(R.string.info_activity_title);
}

Remember to add this string to your strings.xml file also:

App Info

Now run your app! Notice that the InfoActivity Action Bar has a home button and a title in place of the application logo. Tap the home button to return to the home activity you just came from.

Working Android 1.6 source for this post is available on github. To checkout the other features of GreenDroid you can also import the project for the GDCatalog app from the GreenDroid github repository.

热心网友 时间:2022-05-07 00:34

1. ActionBarSherlock

ActionBarSherlock应该算得上是GitHub上最火的Android开源项目了,它是一个的库,通过一个API和主题,开发者就可以很方便地使用所有版本的Android动作栏的设计模式。

对于Android
4.0及更高版本,ActionBarSherlock可以自动使用本地ActionBar实现,而对于之前没有ActionBar功能的版本,基于
Ice Cream Sandwich的自定义动作栏实现将自动围绕布局。能够让开发者轻松开发一款带动作栏(Action
bar)的应用,并且适用于Android 2.x及其以上所有版本。

详情请参考:ActionBarSherlock

2. *-android-sdk

* SDK for Android是一个开源库,允许开发者将*集成到所开发的Android应用中。

如果想要获取更多关于示例、文档、将SDK集成到App中、源代码等信息,可直接登陆* Developers查看。

3. SlidingMenu(SlidingMenu Demos)

SlidingMenu是一个开源的Android库,能够让开发者轻松开发一款应用,实现类似于Google+、Youtube和*应用中非常流行的滑动式菜单。

使用SlidingMenu的Android应用:

Foursquare
Rdio
Plume
VLC for Android
ESPN ScoreCenter
MLS MatchDay
9GAG
Wunderlist 2
The Verge
MTG Familiar
Mantano Reader
Falcon Pro (BETA)
MW3 Barracks

4. cocos2d-x

在移动开发领域,将Cocos2D-X用于主流iOS/Android游戏开发的公司、开发团队多不胜数。cocos2d-x是一个开源的支持多平
台的2D游戏框架,使用C++开发,基于cocos2d-iphone,在MIT许可证下发布。主分支在GitHub上使用OpenGL ES
2.0渲染,而旧版gles11分支则使用OpenGL ES 1.1渲染。

支持iOS、Android、Windows Phone 8、Bada、BlackBerry、Marmalade、Windows、Linux等多个平台。支持C++、Lua、JavaScript编程语言。

5. android

GitHub Android App是
GitHub开源的Android客户端,支持Issues、Gists,并集成了新闻Feed,能够让你及时跟进组织及关注的开发者、库等。同时,该应
用还提供了一个用户快速访问你所创建、监控及发布issue的面板,可查看并将问题加入到收藏夹,可对标签、里程碑和任务进行过滤配置。

android资源库包含了GitHub Android App的所有源代码。

6. Android-ViewPagerIndicator

ViewPager指针项目,在使用ViewPager的时候能够指示ViewPager所在的位置,就像Google Play中切换的效果一样,还能使用在应用初始化的介绍页面。

兼容Android支持库的ViewPager及ActionBarSherlock,最初是基于Patrik Åkerfeldt的ViewFlow,开发者可以直接登陆Google Play下载该项目的演示应用。

7. MonoGame

MonoGame是一个Microsoft XNA 4.x Framework的开源跨平台实现。用于让XNA开发者将他们在Xbox
360、Windows & Windows Phone上开发的游戏移植到iOS、Android、Mac OS
X、Linux及Windows 8 Metro上,目前,PlayStation Mobile & Raspberry
PI的开发正在进行中。

详情请参考:MonoGame

8. Android-PullToRefresh

该项目用于为Android提供一个可重用的下拉刷新部件。它最初来源于Johan Nilsson的库(主要是图形、字符串和动画),但这些后来都已被取代。

9. android-async-http

android-async-http是Android上的一个异步、基于回调的HTTP客户端开发包,建立在Apache的HttpClient库上。

10. Android-Universal-Image-Loader

Android上最让人头疼的莫过于从网络获取图片、显示、回收,任何一个环节有问题都可能直接OOM,这个项目或许能帮到你。

Universal Image Loader for Android的目的是为了实现异步的网络图片加载、缓存及显示,支持多线程异步加载。它最初来源于Fedor Vlasov的项目,且自此之后,经过大规模的重构和改进。

11. GreenDroid

GreenDroid最初是由Cyril Mottier发起,是一个Android的UI开发类库,能够让UI开发更加简便,并且在应用中始终保持一致。

详情请参考:Cyril Mottier's Blog

12. Anki-Android

AnkiDroid是一个免费、开源的Android的闪存应用,可直接从Google Play进行下载。

详情请参考:ankidroid

13. android-actionbar

Action
bar是一个标识应用程序和用户位置的窗口功能,并且给用户提供操作和导航模式。在大多数的情况下,当开发者需要突出展现用户行为或在全局导航的
activity中使用action bar,因为action
bar能够使应用程序给用户提供一致的界面,且系统能够很好地根据不同的屏幕配置来适应操作栏的外观。

Action bar的主要目的:

提供一个用于识别应用程序的标示和用户的位置的专用空间。
在不同的应用程序之间提供一致的导航和视觉体验。
突出Activity的关键操作,并且在可预见的方法内给用户提供快捷的访问。

14. android-viewflow

android-viewflow是Android平台上的一个视图切换的效果库,ViewFlow相当于Android UI部件提供水平滚动的ViewGroup,使用Adapter进行条目绑定。

15. android-mapviewballoons

当使用Android地图外部库(com.google.android.maps)时,android-mapviewballoons会提供一个简单的方式来对地图覆盖进行标注,就是一个简单的信息气泡。

它由BalloonOverlayView组成,是一个代表显示你的MapView及BalloonItemizedOverlay的气泡的视图,BalloonItemizedOverlay是ItemizedOverlay的一个抽象扩展。

16. PushSharp

一个向iOS(iPhone/iPad APNS)、Android(C2DM和GCM)、Windows Phone和Windows 8设备发送推送通知的服务器端库。

17. androidannotations

Android Annotations是一个开源的框架,用于加速 Android应用的开发,可以让你把重点放在功能的实现上,简化了代码,提升了可维护性。

18. HockeyKit

Hockey是一个iOS Ad-Hoc自动更新框架。苹果App
Store中的所有App都可以使用它,它能够显著地提高Beta测试的整个过程,分为两部分:服务器和客户端框架。服务器组件需要所有脚本,但在没有客
户端库的情况下,也可以单独工作。它提供一个Web接口,Beta测试者可以使用它来安装最新的AdHoc配置文件,也可以直接在设备上通过Safari
安装最新的Beta版本。

只需在服务器上安装一次服务端,就可以处理包标识符不同的多个应用程序(有开发者强烈建议对Debug、AdHoc Beta和AppStore发布版使用不同的包标识符)。
默认当App启动或唤醒时,客户端会从服务器检测更新,用户可以在设置对话框中进行修改:一天一次或手动检查更新。
除了支持iOS,HokeyKit也支持Android平台,不过Android版还处在Alpha阶段,支持OTA及应用内更新。
为HockeyKit用户提供服务器托管服务。

19. android-menudrawer

Android上的菜单展示风格各异,其中用得最多且体验最好的莫过于左右滑动来显示隐藏的菜单,android-menudrawer是一个滑动
式菜单实现,允许用户在应用当中实现无缝导航。该项目具有多种菜单展示效果,其中最常见的就是通过屏幕边缘拖动或点击动作栏的“向上”按钮显示。

实现功能:

菜单可以沿着四个边放置。
支持附加一个始终可见、不可拖动的菜单。
菜单的内容和整个窗口都可以隐藏。
可用于XML布局。
显示当前可见屏幕的指示器。

20. android-flip

Aphid FlipView是一个能够实现Flipboard翻页效果的UI组件。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com