Skip to content

Instantly share code, notes, and snippets.

@luthfihariz
Created December 7, 2012 15:52
Show Gist options
  • Save luthfihariz/4234118 to your computer and use it in GitHub Desktop.
Save luthfihariz/4234118 to your computer and use it in GitHub Desktop.
Submenu with Action Bar Sherlock
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu"
android:icon="@drawable/ic_menu"
android:showAsAction="ifRoom">
<menu>
<item
android:id="@+id/browser_intent"
android:icon="@drawable/ic_browser"
android:showAsAction="ifRoom|withText"
android:title="Buka di Browser"/>
<item
android:id="@+id/increase_font"
android:icon="@drawable/maxfont_button_states"
android:showAsAction="always"
android:title="Perbesar Huruf"/>
<item
android:id="@+id/decrease_font"
android:icon="@drawable/minfont_button_states"
android:showAsAction="always"
android:title="Perkecil Huruf"/>
<item
android:id="@+id/share"
android:icon="@drawable/share_button_states"
android:showAsAction="always"
android:title="Bagikan"/>
<item
android:id="@+id/search"
android:icon="@drawable/search_button_states"
android:showAsAction="always"
android:title="Temukan di Kamus"/>
</menu>
</item>
</menu>
//here code before...
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.article_menu, menu);
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelected(
com.actionbarsherlock.view.MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
super.finish();
return true;
case R.id.browser_intent:
showWebView();
return true;
case R.id.share:
shareNews();
return true;
case R.id.decrease_font:
minimizeFont();
return true;
case R.id.increase_font:
maximizeFont();
return true;
case R.id.search:
performSearch();
return true;
}
return true;
}
//here code after...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment