I have a ListView that displays in each row an image pulled from the Internet and a row.
In general, it works great. However, I want to take control when the views (lines) are bloated. By default, when the row is visible, the adapter's getView() method is getView() .
This, of course, is not one of the best behaviors, because if I have a ListView with several hundred entries, and I need to get to them below by scrolling through the ListView method, getView() will be called for each row until I get a footer .
So, I want to call getView only after scrolling, and the ListView is paused / inactive, but I have no idea how to do this:
Here's how I started:
listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if(scrollState==SCROLL_STATE_IDLE){
This is the getView of my adapter:
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.row, parent, false); holder = new ViewHolder(); holder.title = (TextView) convertView.findViewById(R.id.textView); holder.image = (ImageView) convertView.findViewById(R.id.imageView); holder.position = position; convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.title.setText(data.get(position).getTitle()); holder.image.setImageResource(R.drawable.ic_launcher); new LoadImageAsync(data.get(position).getUrl(), holder.image).execute(); return convertView; }
Please give me some instructions where I should look to achieve this: Call getView () only after scrolling and only for visible elements.