Both activities are in the same package
Second activity uses second layout file
setContentView(R.layout.main2);
Errors on this line
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.
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)
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);
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.
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))
.