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

前端 未结 7 862
清酒与你
清酒与你 2020-11-21 08:18

I\'m developing an Android app which reads data from MySQL database and I faced this error. I have this XML layout:



        
相关标签:
7条回答
  • 2020-11-21 08:47

    Change

    dateTime.setText(app.getTotalDl());
    

    To

    dateTime.setText(String.valueOf(app.getTotalDl()));
    

    There are different versions of setText - one takes a String and one takes an int resource id. If you pass it an integer it will try to look for the corresponding string resource id - which it can't find, which is your error.

    I guess app.getTotalDl() returns an int. You need to specifically tell setText to set it to the String value of this int.

    setText (int resid) vs setText (CharSequence text)

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