/*
* 根据名字返回各种文件的索引
* layout
* id
* drawable
* attr
* string
* style
*/
public static int getString(Context context , String name){
return context.getResources().getIdentifier(name, "string", context.getApplicationContext().getPackageName());
}
//使用方法
tv.setText(getString(context,name));
资源索引
最新推荐文章于 2021-01-09 01:24:32 发布