当前位置: 代码迷 >> Android >> 急怎么在java代码中获取string.xml中的字符串
  详细解决方案

急怎么在java代码中获取string.xml中的字符串

热度:44   发布时间:2016-04-28 06:33:54.0
急!如何在java代码中获取string.xml中的字符串!
String str = Resources.getSystem().getText(com.derbysoft.hotel.R.string.hello).toString();

String str = Resources.getSystem().getString(R.string.hello);

上面2个都试过了,抛异常
NotFoundException
说找不到对应的ID,但是string.xml文件中明明有,R文件中也有ID

不知道什么原因,大家帮帮忙看下!
------解决方案--------------------
String str=getResources().getString(R.string.hello_world);
  相关解决方案