Android Actionbar Left Menu

廉价感情. 提交于 2019-12-23 12:53:08

问题


I am working on android application. I have to add a menu on the left side of Action Bar. I am able to add menu on the right side but along with right side menu, I also want to add a menu on left side of Action Bar just like :

I have spent hours on searching how to achieve that left side menu, but no success. How can I achieve that? Thanks!


回答1:


This is called Navigation Drawer, You can look at the official android tutorial here, and this one too




回答2:


You cant align menu to left .you should use customview for your actionbar




回答3:


If you are not specifically into the navigational drawer, like a back button or anything you like, you can use

ActionBar actionbar = getSupportActionBar();
actionbar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp);

and call

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() ==android.R.id.home){
            //todo work here
            return true;
        }
        return super.onOptionsItemSelected(item);
    }


来源:https://stackoverflow.com/questions/22044641/android-actionbar-left-menu

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