以XML定义的布尔值。如何在Java中引用? [英] A boolean value defined in XML. How to reference in Java?
本文介绍了以XML定义的布尔值。如何在Java中引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一些引用bool.xml文件的代码,并引用bool中的当前值。
I'm trying to write some code that will reference a bool.xml file and will reference the current value inside the bool.
<bool name="enableQAurl">true</bool>
有了这个,我希望能够在代码中引用它,这样如果它被设置为True它做某事,如果做错,做其他事。只是一个简单的If和else语句。
With this I want to be able to reference this in code, so that if it's set to True it does something and if false does something else. Just a simple If and else statement.
非常感谢任何代码引用或反馈。
Any code references or feedback is greatly appreciated.
推荐答案
Resources res = getResources();
boolean enableQAurl = res.getBoolean(R.bool.enableQAurl);
来源:
http://developer.android.com/guide/topics/resources/more-resources.html
这篇关于以XML定义的布尔值。如何在Java中引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文