gpt4 book ai didi

android - 如何以编程方式将 home 更改为 up 资源?

转载 作者:IT老高 更新时间:2023-10-28 23:17:41 27 4
gpt4 key购买 nike

我知道如何 change the homeAsUpIndicator in the styles xml file . 问题是如何以编程方式更改它

我想这样做的原因是因为在某些 View 中我支持侧边导航(滑动菜单) - 按上/后标题按钮,显示侧边菜单。

在其他 View 中,我支持自然上/后按钮。

因此,我想使用不同的指示器图标来指示两种不同的逻辑 - 侧边导航与向上/后退。

请不要争论这样做的动机。那是给定的状态。谢谢。

最佳答案

int upId = Resources.getSystem().getIdentifier("up", "id", "android");
if (upId > 0) {
ImageView up = (ImageView) findViewById(upId);
up.setImageResource(R.drawable.ic_drawer_indicator);
}

关于android - 如何以编程方式将 home 更改为 up 资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16394755/

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