Listview items Animation Stop While Scrolling
Asked Answered
S

3

16

I am trying to show ProgressBar with a simple animation for each ListView item, but when I am scrolling, the ProgressBar animation stops. After scrolling ends the animation starts again. See image below.

Link
(source: axgig.com)

Salicylate answered 25/5, 2014 at 21:19 Comment(1)
For the close votes because unclear what the OP is asking, I think it's pretty obvious on the contrary. He want to know how to keep the progress bar animation when scrolling occurs.Babyblueeyes
S
10

I used This Syntax in my Adapter And problem solved !

public class AdapterDownload extends ArrayAdapter<StructDownload> {

public AdapterDownload(ArrayList<StructDownload> array) {
    super(G.context, R.layout.item_layout, array);
}


private static class ViewHolder {

    public ViewHolder(View view)
    {

    }


    public void fill(final ArrayAdapter<StructDownload> adapter, final StructDownload item, final int position)
    {

    }
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {

}

}

Thank You.

Salicylate answered 25/5, 2014 at 23:20 Comment(0)
V
13

you must use animation in getView() and set animation for convertView example :

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;

    StructureArticles item = getItem(position);
    if (convertView == null) {
        convertView = G.inflater.inflate(R.layout.adapter_articles, parent, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.fill(this, item, position);
    Animation animationListView = AnimationUtils.loadAnimation(context, R.anim.scale_fade_in);
    convertView.startAnimation(animationListView);

    return convertView;
}
Vertigo answered 26/5, 2014 at 4:25 Comment(0)
S
10

I used This Syntax in my Adapter And problem solved !

public class AdapterDownload extends ArrayAdapter<StructDownload> {

public AdapterDownload(ArrayList<StructDownload> array) {
    super(G.context, R.layout.item_layout, array);
}


private static class ViewHolder {

    public ViewHolder(View view)
    {

    }


    public void fill(final ArrayAdapter<StructDownload> adapter, final StructDownload item, final int position)
    {

    }
}


@Override
public View getView(int position, View convertView, ViewGroup parent) {

}

}

Thank You.

Salicylate answered 25/5, 2014 at 23:20 Comment(0)
T
3

It is stopping because getview is called again and again when list items are visible thus resetting the view to avoid any frame skips/lag on the devices..

what you need to do is to create a view holder with boolean and set it as a tag to the view.. each time is it animating boolean should be true and false when it stops.. so when getview is called your progressbar animation is still starting or stopping depending on the boolean..

Thrave answered 25/5, 2014 at 22:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.