开发者

How can I change Swingworker to AsyncTask in Android?

How can I change Swingworker to AsyncTask in Android?

My code is as follows.

private void showWeather() {
        // TODO Auto-generated method stub
         SwingWorker worker = new SwingWorker<WeatherInfo,Object>()
         {
             public WeatherInfo doInBackground()
开发者_如何学Go             {
                 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();
    }


You should be using AsyncTask instead

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜