Search code examples
androidlistviewprogress-barsimplecursoradapter

How to keep progress bar state while scrolling in listview


I have a horizontal progressbar in a each listview row. While i select a row and upload, i am scrolling down and when i come back to the row that i was uploding, the progressbar is gone(it is not saving the state when it goes off screen). I am using SimpleCursorAdapter and sqlite. I have seen this working, like the android market app, and they do it well. Any help? I have been on this for days.


Solution

  • public View getView(final int position, View convertView, ViewGroup parent) {
    
        ProgressBar progressBar = (ProgressBar)view.findViewById(R.id.progressBar);
        Rect bounds = progressBar.getProgressDrawable().getBounds();
    
        ... do your work here
    
        //reset the bounds before return the view
        progressBar.getProgressDrawable().setBounds(bounds);
    
        return view;
    }