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