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

前端 未结 7 861
清酒与你
清酒与你 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:26

    You can do it. this is a easy way.

    txtTopicNo.setText(10+"");
    
    0 讨论(0)
  • 2020-11-21 08:29

    if you get the values in int you have to use string for that it is throwing the error

    before

      holder.villageName.setText(villageModelList.get(position).getVillageName());
        holder.villageCount.setText(villageModelList.get(position).getPeopleCount());
        holder.peopleCount.setText(villageModelList.get(position).getPeopleCount());
    

    after

      holder.villageName.setText(villageModelList.get(position).getVillageName());
        holder.villageCount.setText(String.valueOf(villageModelList.get(position).getPeopleCount()));
        holder.peopleCount.setText(String.valueOf(villageModelList.get(position).getPeopleCount()));
    

    you can solve the error by adding the String.valueOf

    0 讨论(0)
  • 2020-11-21 08:32

    Replace

    dateTime.setText(app.getTotalDl());
    

    With

    dateTime.setText(""+app.getTotalDl());
    
    0 讨论(0)
  • 2020-11-21 08:32

    The evaluated value for settext was integer so it went to see a resource attached to it but it was not found, you wanted to set text so it should be string so convert integer into string by attaching .toStringe or String.valueOf(int) will solve your problem!

    0 讨论(0)
  • 2020-11-21 08:33

    When you try to set text in Edittext or textview you should pass only String format.

    dateTime.setText(app.getTotalDl());
    

    to

    dateTime.setText(String.valueOf(app.getTotalDl()));
    
    0 讨论(0)
  • 2020-11-21 08:34

    If we get the value as int and we set it to String, the error occurs. PFB my solution,

    Textview = tv_property_count;
    int property_id;
    tv_property_count.setText(String.valueOf(property_id));
    
    0 讨论(0)
提交回复
热议问题