0

hello all i have made one adpter class in that listCountry.size(); in getcount shows me the actual size that is of 500. But the getview call o*nly for 11 time*

public class ImageAdapter extends BaseAdapter {
        BitmapFactory.Options bmop;
        private ArrayList<String> listCountry;
        private Activity activity;

        public ImageAdapter(Activity activity, ArrayList<String> listCountry) {
            super();

            // this.listCountry = listCountry;
            this.listCountry = new ArrayList<String>();
            this.listCountry = listCountry;

            this.activity = activity;
            System.out.println("this is contry name " + this.listCountry);

        }

        @Override
        public int getCount() {
            System.out.println("len " + listCountry.size());// this shows 500
            return listCountry.size();
        }

        @Override
        public Object getItem(int position) {

            return listCountry.get(position);
        }

        @Override
        public long getItemId(int arg0) {
            // TODO Auto-generated method stub
            return arg0;
        }

        @Override
        public View getView(int arg0, View convertView, ViewGroup parent) {
            ViewHolder view;
            LayoutInflater inflator = activity.getLayoutInflater();
            if (convertView == null) {
                System.out.println(arg0+" this is from Adpter "+listCountry.get(arg0) );// this shows only first 11
                view = new ViewHolder();
                convertView = inflator.inflate(R.layout.item_grid_image, null);

                // Typeface typeface =
                // Typeface.createFromAsset(getAssets(),"fonts/DroidSerif.ttf");

                view.imgViewFlag = (ImageView) convertView
                        .findViewById(R.id.image);
                view.pb = (ProgressBar) convertView
                        .findViewById(R.id.progressBar1);

                // d.execute("http://java.sogeti.nl/JavaBlog/wp-content/uploads/2009/04/android_icon_256.png");

                // view.imgViewFlag.setBackgroundResource(R.drawable.view_default);
                convertView.setTag(view);

            } else {
                view = (ViewHolder) convertView.getTag();
            }
            try {
                // view.txtViewTitle.setText(listCountry.get(position));
                // view.imgViewFlag.setImageResource(listFlag.get(position));
                //DownloadImageTask d = new DownloadImageTask(view.imgViewFlag);
            //  d.execute(listCountry.get(arg0));

            } catch (Exception e) {
                System.out.println("this is error " + e.getMessage());
            }

            return convertView;
        }

    }
Charles
  • 50,010
  • 13
  • 100
  • 141
Android
  • 8,757
  • 9
  • 65
  • 108

1 Answers1

0

It will only populate the list with the items that can fit your screen size and are visible to you. if you are using large images then you can feel the lag caused by this method

Aditya_Anand
  • 519
  • 5
  • 17