There was a need to create a menu
with submenu
in action bar
, equal to this:
Couldyouhelpme?
MyXML
menu:
<menuxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:apk="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_atualizar"
android:title="@string/menu_atualizar"
apk:showAsAction="ifRoom"
/>
</menu>
My code:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_atualizar:
//código aqui...
default:
return super.onOptionsItemSelected(item);
}
}