which the smooth and fast way to load image from net in android list view!

前端 未结 6 1426
感动是毒
感动是毒 2021-02-06 19:33

i need to list out data from net in that i have 1 image and 2 text. i parse all data and display it but the image displaying very slow in list. so i m looking for best way to do

6条回答
  •  离开以前
    2021-02-06 20:17

    FYI

    Chirag Raval answer works but you need the Utils class too.

    import java.io.InputStream;
    import java.io.OutputStream;
    
    public class Utils {
        public static void CopyStream(InputStream is, OutputStream os)
        {
            final int buffer_size=1024;
            try
            {
                byte[] bytes=new byte[buffer_size];
                for(;;)
                {
                  int count=is.read(bytes, 0, buffer_size);
                  if(count==-1)
                      break;
                  os.write(bytes, 0, count);
                }
            }
            catch(Exception ex){}
        }
    }
    

    You can read more about this here

提交回复
热议问题