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

前端 未结 1 707
刺人心
刺人心 2021-02-11 06:11

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

1条回答
  •  伪装坚强ぢ
    2021-02-11 07:15

    //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

    0 讨论(0)
提交回复
热议问题