取Strings资源:
Fragment里获取:
getString(resId)
或者直接R.string.XXXX
示例:
1.自定义占位符、填充value
<string name="pay_pf_payFunction">%1$s = 应收款 - 已收款\n%2$s = %3$s - %4$s</string>
其中%1$s、%2$s、%3$s、%4$s,为占位符,填充值时:
getString(R.string.pay_pf_payFunction, "1", "2", "3", "4");
2.普通声明常量,代码里引用
String value=getString(R.string.pay_pf_payFunction);
取Drawable资源:
getResources().getDrawable(R.drawable.pay_selected))
取Color资源:
getResources().getColor(R.color.colorAccent)