Summary of built-in actionbar in android system

Source: Internet
Author: User

Summary of built-in actionbar in android system

The actionbar introduced by different android versions is different. The following is a summary:

1. In the support. v7 package

Introduce layout using the parameter inflate in the onCreateOptionsMenu Method

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

         

See 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 activity

To introduce the layout, use the getMenuInflate method under the activity.

public class ArticleListActivity extends Activity {    @Override    public boolean onCreateOptionsMenu(Menu menu) {        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

 

     

 

 

 

 

Refer:

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

:

 

 

When there are already too many other users

Related Article

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.