如何在家转变为建立资源编程? [英] How to change home as up resource programmatically?

查看:106
本文介绍了如何在家转变为建立资源编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何更改样式的XML文件的homeAsUpIndicator。 现在的问题是怎么改编程

我想这样做,因为在某些观点我支持的原因侧导航(滑动菜单) - pressing上/回标题按钮,显示侧面菜单

在其他的意见,我支持在自然向上/回钮。

因此​​,我想不同的指示器图标来表示两个不同的逻辑 - 侧面导航与上/回

请,让我们不要在这样做的动机争论。这是在给​​定的状态。谢谢你。

解决方案

  INT UPID = Resources.getSystem()则getIdentifier(上,ID,机器人)。
如果(UPID大于0){
    ImageView的上升=(ImageView的)findViewById(UPID);
    up.setImageResource(R.drawable.ic_drawer_indicator);
}
 

I know how to change the homeAsUpIndicator in the styles xml file. The question is how to change it programmatically.

The reason I want to do it because in some views I support side navigation (sliding menu) - pressing the up/back title button, shows the side menu.

In other views I support the natural up/back botton.

Thus I would like to different indicator icons to indicate the two different logics - side navigation vs. up/back.

Please, lets not argue on the motivation of doing this. That's the given state. Thanks.

解决方案

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

这篇关于如何在家转变为建立资源编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆