ActionBarCompat - 如何用它用它、ActionBarCompat

2023-09-12 02:03:17 作者:献世.

我试图用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 。你可以找到它here或根据<您当地的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:

在这里你声明的项目进行操作栏(见http://developer.android.com/resources/samples/ActionBarCompat/res/menu/main.html) $ C C扩展 ActionBarActivity 的活动$ 覆盖 onCreateOptionsMenu(),使其膨胀的菜单中,您codeD步骤#1 覆盖 onOptionsItemSelected()让您处理当用户点击任何您在步骤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) Code an Activity that extends ActionBarActivity Override onCreateOptionsMenu() so that it inflates the menu you coded in step #1 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.