如何在家转变为建立资源编程? [英] How to change home as up resource programmatically?
问题描述
我知道如何更改样式的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屋!