일반 Android보기 (목록보기 아님)의 ImageView에있는 URL에서 이미지를 빠르게로드하는 방법은 무엇입니까?

사용자 3890749

내 인터넷 연결이 매우 빠릅니다. 그럼에도 불구하고 내 이미지가 앱에서 매우 느리게로드됩니다. 다음은 내가 사용한 코드입니다. 제안 된대로 비동기 메서드를 사용하여 특정 작업을 별도로 수행했습니다.

public class ItemPage extends Activity{
ImageView image;
String url;
@Override
    protected void onCreate(Bundle savedInstanceState) {
image = (ImageView) findViewById(R.id.img);
//getting url from the parent activity
Intent intent = getIntent();
         Bundle extras = intent.getExtras();
            if(extras != null) url = extras.getString("bigurl");
//async call
           new DownloadFilesTask().execute(); 
}

 private class DownloadFilesTask extends AsyncTask<Void, Void, Void> { //working part
                     Drawable drawable;

                     @Override
                     protected Void doInBackground(Void... params) {
                     try {
                        drawable =drawableFromUrl(url);

                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                      return null;
                     }
                     protected void onPostExecute(Void result) {
                         image.setImageDrawable(drawable);
                    }          
                } 
              public static Drawable drawableFromUrl(String url) throws IOException {
                    Bitmap x;

                    HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
                    connection.connect();
                    InputStream input = connection.getInputStream();

                    x = BitmapFactory.decodeStream(input);
                    return new BitmapDrawable(x);
                }
}

제발 도와주세요. URL에서 이미지를 더 빨리로드 할 수있는 방법이 있습니까? 시간 내 주셔서 미리 감사드립니다.

딜라 바르 말렉

Aquery Library를 사용하고 싶다고 생각합니다. 이미지를 매우 빠르게로드합니다.

링크를 참조하십시오

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관