0

I want to open my photos, set to a string representing the address (http). Create SimpleAdapter and his pass strings.

final ArrayList<HashMap<String,String>> CategoryList = UpdateMenuFromServer.getCategories();
final ListView ListCatalog = (ListView)findViewById(R.id.listView);
SimpleAdapter CatAdapter =new SimpleAdapter(this, CategoryList, R.layout.category_,
                    new String[] {"Name", "Image"},
                    new int[] {R.id.ProducerText, R.id.ProducerImage});

            ListCatalog.setAdapter(CatAdapter);

R.id.ProducerImage was treated Class CustomImageView

public class CustomImageView extends ImageView{

    private static Context context;



    public CustomImageView(Context context) {
        super(context);
        this.context = context;
    }

    public CustomImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }
    public CustomImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        this.context = context;
    }

    public void setImageURI (Uri uri1){
        try {
            URL url = new URL(uri1.toString());

            LoadImage load = new LoadImage(url);
            load.execute();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public class LoadImage extends AsyncTask<Void, Void, Drawable> {

        private URL Url;
        public LoadImage(URL url){
            Url = url;
        }
        @Override
        protected Drawable doInBackground(Void... voids) {
            Drawable ShowImage = null;
            try {
                ShowImage = Drawable.createFromStream(Url.openStream(), null);
            } catch (IOException e) {
                //e.printStackTrace();
            }

            return ShowImage;
        }

        protected void onPostExecute(Drawable ShowImage) {
            if(ShowImage!=null)
                setImageDrawable(ShowImage.getCurrent());
        }
    }
}

ListView when loading the first element see it change all the pictures and only then load the other elements. My question is how can I avoid it and loading ListView to open my pictures already loaded.

user2637087
  • 65
  • 1
  • 5
  • One good library available developed by nostra https://github.com/nostra13/Android-Universal-Image-Loader. You should try this. This has good features. :) – Chintan Rathod Aug 01 '13 at 06:48
  • I'm doing something similar HERE!!!http://stackoverflow.com/questions/18808114/picasso-loading-of-image-spawned-inside-asynctask – Etienne Lawlor Sep 15 '13 at 01:56
  • You may want to see my own answer to my question:https://stackoverflow.com/questions/44216331/image-thumbnails-not-setting-correctly/44528936#44528936 – Pushan Gupta Jun 13 '17 at 18:35

0 Answers0