无法解析符号execute()

时间:2016-01-07 11:59:30

标签: android android-asynctask

我有错误,无法解析符号execute

我正在调用execute()类的AsyncTask方法 我试过修改参数但它没有工作

代码:

LoadImageFromURL loadImage = new LoadImageFromURL();
loadImage.execute();

类别:

private class LoadImageFromURL extends AsyncTask<String, Integer ,Bitmap> {
        @Override
        protected Bitmap doInBackground(String... params) {
            try {
                URL url = new URL(urlFlag);
                InputStream is = url.openConnection().getInputStream();
                Bitmap bitMap = BitmapFactory.decodeStream(is);
                return bitMap;

            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;

        }

        @Override
        protected void onPostExecute(Bitmap result) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            iv.setImageBitmap(result);
        }
}

1 个答案:

答案 0 :(得分:3)

修改下面的代码 -

1. private class LoadImageFromURL extends AsyncTask<String, Integer ,Bitmap> {
2. protected Bitmap doInBackground(String... params) {

1. private class LoadImageFromURL extends AsyncTask<Void, Integer ,Bitmap> {
2. protected Bitmap doInBackground(Void... params) {