【发布时间】:2015-06-01 19:33:06
【问题描述】:
我有问题。为什么 setText 方法中的数据设置不正确?
MainActivity 类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textViewCity = (TextView) findViewById(R.id.text_view_city_name);
textViewTemperature = (TextView) findViewById(R.id.text_view_current_temperature);
new Thread(new WeatherYahoo()).start();
Weather weather = new Weather();
textViewCity.setText(weather.getCity());
textViewTemperature.setText(String.valueOf(weather.getTemperature()));
}
数据已在 Weather 类中正确下载并设置(我使用 JSON),但屏幕上显示 textViewCity 形式为空字符串,textViewTemperature 为 0。
【问题讨论】:
-
你能显示天气吗,构造函数?
-
在访问天气对象之前,您似乎没有设置任何属性。
标签: android