Settext Doesn't Set Text
I have a class that fetches som data from a website. I've followed TheNewBoston's tutorial (147-149 I think) and copied what he writes exactly, but it doesn't work for me. The prob
Solution 1:
replace:
try {
returned = test.getInternetData();
tv.setText(returned);
} catch (Exception e) {
e.printStackTrace();
}
by
try {
returned = test.getInternetData();
tv.setText("returned");
} catch (Exception e) {
e.printStackTrace();
tv.setText(e.getMessage());
}
setText will then set Text as you requested!
Solution 2:
Try this:
String returned = "some default string.";
try {
returned = test.getInternetData();
} catch (Exception e) {
e.printStackTrace();
}
tv.setText(returned);
This way, you know that setText will be called with data, regardless of if there was an exception.
Solution 3:
runOnUiThread(new Runnable()
{
publicvoidrun()
{
tv.setText(returned.toString());
}
});
Post a Comment for "Settext Doesn't Set Text"