Hi guys i am stuck with image caching. i need to populate Linear Layout with images from web.
I was searching examples how to cache images in android and found these examples:
- http://developer.android.com/resources/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.html
- Lazy load of images in ListView
I tried it implement for my code.
    String picPath = "https://www.google.lt/logos/classicplus.png";
    try {
        /*
        View v = null;//new View(this);
        ImageLoader loader = new ImageLoader(this);
        ImageView im = (ImageView)this.findViewById(R.id.image);
        loader.DisplayImage(picPath, im);
        addImage( im);*/
          LayoutInflater inflater =(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           View convertView = inflater.inflate(R.layout.item, null);
        ImageView image = (ImageView)convertView.findViewById(R.id.image);
        ImageDownloader down = new ImageDownloader();
        down.download(picPath, image);
        addImage(image);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
    public void addImage( View view){
        LinearLayout pubLayout = (LinearLayout)findViewById( R.id.scrollerLinearlayout);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                 LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        //setting layout_margin
        params.setMargins(15, 30, 15, 30);
        pubLayout.addView(view,params);
}
However this didn't worked. I believe because i add view to linear layout and when image is downloaded it can't repaint it ?
There are examples how to do image caching using ListView. But what to do if i am not using List View.
I would write my own caching but how to make callback to image downloaded as i want first add image to layout and on callback update it ?
Thanks.
 
    