如何将此导航抽屉图标更改为后退箭头,以使活动返回到另一个活动

问题描述 投票:0回答:2

我需要将此抽屉图标更改为后退箭头,以将详细信息活动更改为列表活动。

Code image

android navigation android-navigation-drawer
2个回答
0
投票
Toolbar toolbar = (Toolbar) findViewById(R.id.your_tool_bar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.your_arrow_icon);

我建议你读这个

https://developer.android.com/training/implementing-navigation/nav-drawer#java


0
投票

你可以使用ActionBarDrawerToggle

final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);      
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, 
R.string.navigation_drawer_open, R.string.navigation_drawer_close);

toggle.setDrawerIndicatorEnabled(false);
toggle.setHomeAsUpIndicator(R.drawable.myicon);//your preferred drawable image here

toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        drawer.openDrawer(GravityCompat.START);
    }
});
© www.soinside.com 2019 - 2024. All rights reserved.