ActionBarCompat - 如何用它 [英] ActionBarCompat - how to use it

查看:122
本文介绍了ActionBarCompat - 如何用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用ActionBarCompat我自己的项目。 我已经打开示例项目(http://developer.android.com/resources/samples/ActionBarCompat/index.html),但我不知道如何实现它在我自己的。

I'm trying to use ActionBarCompat on my own project. I've already opened the sample project (http://developer.android.com/resources/samples/ActionBarCompat/index.html), But I don't know how to implement it on my own.

我找不到某种任何教程。 我应该做这个项目作为一个库? 有人可以给我一些指示,请。

I can't find any tutorial of some kind. Should I make this project as a library? Can someone give me some directions, please.

推荐答案

至于实施,只是坚持了 MainActivity.java 类所提供的样品code 。你可以找到它<一个href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/MainActivity.html">here或根据&lt;您当地的Andr​​oid软件开发工具包folder>/samples/android-15/ActionBarCompat/src/com/example/android/actionbarcompat/MainActivity.java.一般情况下,所有你需要做的是以下内容:

As for implementation, just stick to the sample code provided under the MainActivity.java class. You can find it here or under <your local android-sdks folder>/samples/android-15/ActionBarCompat/src/com/example/android/actionbarcompat/MainActivity.java. In general, all you need to do is the following:

  1. 在这里你声明的项目进行操作栏(见http://developer.android.com/resources/samples/ActionBarCompat/res/menu/main.html)
  2. $ C C扩展 ActionBarActivity
  3. 的活动$
  4. 覆盖 onCreateOptionsMenu(),使其膨胀的菜单中,您codeD步骤#1
  5. 覆盖 onOptionsItemSelected()让您处理当用户点击任何您在步骤1中定义的动作条项目的情况。
  1. Code a menu resource where you declare the items for the action bar (See http://developer.android.com/resources/samples/ActionBarCompat/res/menu/main.html)
  2. Code an Activity that extends ActionBarActivity
  3. Override onCreateOptionsMenu() so that it inflates the menu you coded in step #1
  4. Override onOptionsItemSelected() so that you handle the event when the user taps any of the ActionBar items you defined in step #1.

我觉得很有道理打造一个Android库项目出了ActionBarCompat code;那么你可以从你的自定义Android项目引用它。记住它的的的Apache许可证授权,2.0版的。

I think it makes sense to build an Android Library project out of the ActionBarCompat code; then you can just reference it from your custom Android project. Remember it's licensed under the Apache License, Version 2.0.

这篇关于ActionBarCompat - 如何用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆