ERROR No package identifier when getting value for resource number

后端 未结 11 2092
醉话见心
醉话见心 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 10:53

    From Android TextView Documentation:

    • setText(int resid) Sets the text to be displayed using a string resource identifier.
    0 讨论(0)
  • 2020-12-03 10:54

    It is due to typecast error. You have to try this- TextView.setText(Integer.toString(variable_name));

    Here toString is used to convert integer to string for showing text.

    0 讨论(0)
  • 2020-12-03 10:55

    I was using Picasso library to load image from the network. The urls are in a ArrayList I wasn't using arraylist.get() to get the position of the url in the ArrayList.

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

    face with the same error

    finally i found its not a error due to your xml layout

    somewhere in your code set TextView.setText(int)

    try TextView.setText( Integer.toString(int));

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

    I recently had this problem, when i was trying to integrate SocialAuth libray with my Android application with Android Studio. What was my problem was, some of my resources like facebook icon, were in the mipamp folder. I moved it to drawables folder and the issue got fixed.

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

    Just for the protocol, You could also use:

    TextView.setText("" + intVar) instead of TextView.setText(intVar)

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