Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
android : Embed tabs as a part of actionbar.... as done in shazaam apps
//In onCreate after initializing actionbar
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= VERSION_CODES.ICE_CREAM_SANDWICH) {
// Do something for froyo and above versions
try {
Field actionBarField = actionBar.getClass().getDeclaredField("mActionBar");
} catch (Exception e) {
Log.e(TAG, "Error enabling embedded tabs", e);
} else {
// do something for phones running an SDK before froyo
//code for enableEmbeddedTabs
private void enableEmbeddedTabs(Object actionBar) {
try {
Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class);
setHasEmbeddedTabsMethod.invoke(actionBar, true);
} catch (Exception e) {
Log.e(TAG, "Error marking actionbar embedded", e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment