如何在Android中将Swingworker更改为AsyncTask?如何在Android中将Swingworker更改为AsyncTask?
我的代码如下。
private void showWeather() {
// TODO Auto-generated method stub
SwingWorker worker = new SwingWorker<WeatherInfo,Object>()
{
public WeatherInfo doInBackground()
{
YahooWeather yahooWeather = new YahooWeather();
return yahooWeather.getWeatherInfo();
}
public void done()
{
try {
WeatherInfo wInfo = get(); // get WeatherInfo result from background thread
updateGUI(wInfo);
}
catch(Exception e){}
}
};
worker.execute();
}
它在SwingWorker的工作人员=新的SwingWorker() –
,它必须在得到错误()有错误; –
“,它在get()时出错;”不是很有帮助。这是一个编译错误?你在运行时是否收到异常?哪一个? –