android.content.res.Resources$NotFoundException: String array resource ID #0x7f070002

回眸只為那壹抹淺笑 提交于 2019-11-30 07:19:47

Make sure you don't have variants of the values resources, with the string array defined only for a subset of the variants. For example:

values-v21/strings.xml - defined
values/strings.xml - not defined

If the resource is present in at least one variant, you get the entry in R and can refer to it in code, but the runtime resource file variant does not necessarily have the resource.

I got this error because I used TextView.setText(int) to set a number in the text. The problem is that Android thinks that the integer is a ressource id. Therefore I should encapsulate the interger inside of String.valueOf(int) so the code becomes TextView.setText(String.valueOf(int));

I solve the problem. Juste create a values/strings.xml file with all your string values define in values-v21/strings.xml.

Do this to render Integer to textview

TextView.setText(String.valueOf(int));
Prashant Yalatwar

in my case array.xml was in w820dp version. i just created another in values.xml without w820dp. Works!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!