gpt4 book ai didi

android - 从工具栏 AppCompat 的 SearchView 中删除后退按钮

转载 作者:行者123 更新时间:2023-12-02 17:52:05 25 4
gpt4 key购买 nike

enter image description here

当搜索 View 显示在工具栏(AppCompat)中时,如何删除后退按钮图标?

toolbar = (Toolbar) findViewById(R.id.tool_bar);


// Set an OnMenuItemClickListener to handle menu item clicks
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
// Handle the menu item
return true;
}
});

// Inflate a menu to be displayed in the toolbar
toolbar.inflateMenu(R.menu.menu_main);
toolbar.setTitle("");


setSupportActionBar(toolbar);
actionBar = getSupportActionBar();

// this works for normal back button but not for one appears on tapping SearchView
actionBar.setDisplayHomeAsUpEnabled(false);

最佳答案

用途:

getSupportActionBar().setDisplayHomeAsUpEnabled(false);

toolbar.setNavigationIcon(null);

或者

toolbar.setNavigationIcon(getResources().getColor(android.R.color.transparent));

关于android - 从工具栏 AppCompat 的 SearchView 中删除后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29959309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com