现在的位置: 首页 > 综合 > 正文

String转换成资源id以及String id转换成字符串,两者间的转换

2014年10月04日 ⁄ 综合 ⁄ 共 252字 ⁄ 字号 评论关闭

1,将Android中xml文件中有的字符串,根据string转换成资源id:

   Resources res = TouchDeomActivity.this.getResources();  
		 int titleid=res.getIdentifier(title,//需要转换的资源名称
				"string",        //资源类型 
		  		"com.spring.sky.cycle.touch");//R类所在的包名
		

2,将R.string.***,字符串资源id转换成字符串


    String a=context.getString(resId);

抱歉!评论已关闭.