Android ListView issues with Dynamic Refresh

Source: Internet
Author: User

The rollback of the item in the ListView will result in a reuse.

That is, the ListView cache item is certain, after scrolling, update, will be reused in front of the item is no longer used.

So when updating a control, especially a progress bar, it is necessary to judge whether the currently updated item is in the visible item

That is in

listview.getfirstvisibleposition () and between Listview.getlastvisibleposition ()

If it is not, you need to calculate the location that corresponds to which visual item, and then get that item to update the data.

Attach Code Snippet

int firstvisibleposition = musiclistview.getfirstvisibleposition ();

int lastvisibleposition = musiclistview.getlastvisibleposition ();

if (position >= firstvisibleposition && index <= lastvisibleposition< c15>) {

View view = Musiclistview.getchildat (position - firstvisibleposition);

if (view.gettag () instanceof Listadapter.inneritem) {

listadapter.inneritem inneritem = (listadapter.inneritem) View.gettag ();

inneritem. Progreddbar.setprogress ((float) progress/100.0f);

}

}

Android ListView issues with Dynamic Refresh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.