如何在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()時出錯;」不是很有幫助。這是一個編譯錯誤?你在運行時是否收到異常?哪一個? –