Add this to your mainactivity:
@Override public boolean onCreateOptionsMenu(Menu menu){ // Create menu // See onOptionItemSelected for actions when clicked Menu settingsMenu = menu; // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.optionmenu, menu); MenuItem settingsMenuLogin = settingsMenu.findItem(R.id.settingsMenuExport); return true; }
and
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.settingsMenuExport) { // add additional check Intent i = new Intent(getApplicationContext(), export.class); startActivity(i); } return super.onOptionsItemSelected(item); }
and create an xml in res\menu like this:
optionmenu.xml
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/settingsMenuExport" android:orderInCategory="100" android:title="Export" app:showAsAction="never" /> </menu>
6174 Total Views 1 Views Today