Search code examples
androidandroid-widgetandroid-actionbaractionbarsherlock

Display buttons in main actionbar by using actionbarsherlock


I have just started actionbar using actionbarsherlock. I have implemented it succesfully. I have used splitactionbarwhen narrow and splitted into main actionbar,tabbar,bottom bar. My question is how to add different icons in bottom bar and differnt icons in main actionbar? I am restricting my app into portrait mode only.


Solution

  • We cannot add icons in main actionbar so instead we can use custom view in actionbar by using these statements

    actionbar = getSupportActionBar();
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setDisplayShowTitleEnabled(false);
    actionbar.setDisplayShowCustomEnabled(true);
    
    View actionbar1 = LayoutInflater.from(this).inflate(R.layout.action_custom, null);
    actionbar.setCustomView(actionbar1);