Android system comes with Actionbar summary

Source: Internet
Author: User

The different versions of Android introduced by Actionbar have differences and are summarized below

One, in the support.v7 package

Introduce layouts using the parameters in the oncreateoptionsmenu method: Inflate

Import Android.support.v7.app.actionbaractivity;public class Combolinecolumnchartactivity extends ActionBarActivity {       //menu        @Override public        void Oncreateoptionsmenu (Menu menu, Menuinflater inflater) {            Inflater.inflate (R.menu.combo_line_column_chart, menu);        }        @Override Public        Boolean onoptionsitemselected (MenuItem item) {            int id = item.getitemid ();            if (id = = r.id.action_reset) {                reset ();                Generatedata ();                return true;            }            if (id = = r.id.action_add_line) {                addlinetodata ();                return true;            }            ......            return super.onoptionsitemselected (item);}        }

Layout file:

In the Menu folder

R . Menu . Combo_line_column_chart

<menu xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:app= "http://schemas.android.com/ Apk/res-auto "    xmlns:tools=" Http://schemas.android.com/tools "    tools:context=" Lecho.lib.hellocharts.samples.ComboLineColumnChartActivity ">    <item        android:id=" @+id/action_ Reset "        android:title=" reset chart "        app:showasaction=" never "/>    <item        android:id=" @+id/ Action_add_line "        android:title=" add line "        app:showasaction=" never "/>    <item        android:id = "@+id/action_toggle_lines"        android:title= "Toggle lines/scattered"        app:showasaction= "Never"/></ Menu>

Reference Hellocharts-android/combo_line_column_chart.xml at Master Lecho/hellocharts-android
Https://github.com/lecho/hellocharts-android/blob/master/hellocharts-samples/res/menu/combo_line_column_chart.xml

:

2. In the activity

Introduction of layout to use the Getmenuinflate method under activity

public class Articlelistactivity extends Activity {    @Override public    boolean oncreateoptionsmenu (Menu menu) { C2/>getmenuinflater (). Inflate (r.menu.list, menu);        return true;    }    @Override Public    Boolean onoptionsitemselected (MenuItem item) {        int id = item.getitemid ();        if (id = = r.id.action_settings) {            return true;        }        return super.onoptionsitemselected (item);}    }

Layout code:

In the Menu folder

R.menu.list

<menu xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http://schemas.android.com /tools "    tools:context=". MyActivity ">    <item android:id=" @+id/action_settings "        android:title=" @string/action_settings "        android:orderincategory= "android:showasaction="        never "/></menu>

Reference:

Hellocharts-android/combo_line_column_chart.xml at Master Lecho/hellocharts-android
Https://github.com/lecho/hellocharts-android/blob/master/hellocharts-samples/res/menu/combo_line_column_chart.xml

:






Android system comes with Actionbar summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.