For example, given the following XML located in a file in the res/values directory

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <item name="host" type="setting">10.0.2.2</item>
 <item name="port" type="setting">3000</item>
</resources>

I can now use the following Java syntax within an Android Activity:

String host = getString( R.setting.host );
int port    = getResources().getInteger( R.setting.port );

文章出處 http://mgmblog.com/2010/06/17/android-item-resource-has-a-name-and-type/
arrow
arrow
    全站熱搜

    Chi Learning 發表在 痞客邦 留言(0) 人氣()