ERROR No package identifier when getting value for resource number

后端 未结 11 2181
醉话见心
醉话见心 2020-12-03 10:21

Both activities are in the same package

Second activity uses second layout file

setContentView(R.layout.main2);

Errors on this line

11条回答
  •  长情又很酷
    2020-12-03 11:17

    When you pass an integer to the TextView.setText() to be displayed android assumes it is a resource id and that's why you are getting Resource$NotFoundException. Try converting the int to String before passing it to TextView.setText(): TextView.setText(String.valueOf(i)).

提交回复
热议问题