strings.xml
根据id获取字符串值搞多了,那怎么根据字符串的名称来获取字符串的值呢?
比如在strings.xml有
<string name="app_name">MyAppName</string>
用下面两句来获取:
int resId = context.getResources().getIdentifier( "app_name", "string", "这里填写包名" );
String strValue = context.getResources().getString( resId );
如果是在Application和Activity里面,就不要写context.了