Actionbar like evernote - up button and tabs in one row on top with menu actions at bottom

一笑奈何 提交于 2019-12-05 06:33:26

问题


I have app which has actionbar containing 1) up button which opens side bar menu for navigation just like google plus 2) 2 action menu buttons 3) 2 tabs implemented via view pager

I have successfully implementing actionbar using actionbarsherlock and the result is - >

i want to implement something like evernote app where up button and tabs are in one row and action menu uses split actionbar . i have icons for tabs so fitting them with up button in one row is not an issue

can someone please point me in right direction as to how i can have have up button in the same horizontal bar as tab by modifying actionbarsherlock lib .

Thanks


回答1:


//enabling embedded tabs

//pre-ICS
if (actionBarSherlock instanceof ActionBarImpl) {
    enableEmbeddedTabs(actionBarSherlock);

//ICS and forward
} else if (actionBarSherlock instanceof ActionBarWrapper) {
    try {
        Field actionBarField = actionBarSherlock.getClass().getDeclaredField("mActionBar");
        actionBarField.setAccessible(true);
        enableEmbeddedTabs(actionBarField.get(actionBarSherlock));
    } catch (Exception e) {
        Log.e(TAG, "Error enabling embedded tabs", e);
    }
}

//helper method
private void enableEmbeddedTabs(Object actionBar) {
    try {
        Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class);
        setHasEmbeddedTabsMethod.setAccessible(true);
        setHasEmbeddedTabsMethod.invoke(actionBar, true);
    } catch (Exception e) {
        Log.e(TAG, "Error marking actionbar embedded", e);
    }
}

for further reference - https://groups.google.com/forum/#!topic/actionbarsherlock/hmmB1JqDeCk



来源:https://stackoverflow.com/questions/12761218/actionbar-like-evernote-up-button-and-tabs-in-one-row-on-top-with-menu-actions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!