I\'m developing an Android app which reads data from MySQL database and I faced this error. I have this XML layout:
You can do it. this is a easy way.
txtTopicNo.setText(10+"");
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
Replace
dateTime.setText(app.getTotalDl());
With
dateTime.setText(""+app.getTotalDl());
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!
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()));
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));