ERROR No package identifier when getting value for resource number

后端 未结 11 2093
醉话见心
醉话见心 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:06

    I had the same problem before I come to this post. For me, it was like this: view_element.setText( an_int_value). After casting view_element.setText(String.valueOf(an_int_value));, everything is okay.

    0 讨论(0)
  • 2020-12-03 11:07

    I got the same error while trying to print integer value : TextView.setText(int value). I resolved this error by converting the integer value to string and the i used TextView.setText(converted string value)

    0 讨论(0)
  • 2020-12-03 11:12

    For me I had to go in the XML file for the button. There I noticed a hard coded string value. I had to remove that, and also I had to use Textview.setText("" + intVar);

    0 讨论(0)
  • 2020-12-03 11:14

    I got this same error message when I tried to use TextView.setText passing a char instead of a String. This makes sense since the char would be promoted to an int which meant that I was really calling the

    TextView.setText( int resId );
    

    And since there wasn't a resource with that value, it wouldn't work.

    0 讨论(0)
  • 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)).

    0 讨论(0)
提交回复
热议问题