Scrolling refresh of listview in Android

Source: Internet
Author: User

If a large amount of data is loaded during listview loading, the loading time may be too long and the screen is stuck. To solve this problem, check the SDK,
 
There are two methods in onscrolllistener

You only need to override these two methods to implement rolling loading. For example:
 
Public void onscroll (abslistview V, int firstvisibleitem,
Int visibleitemcount, int totalitemcount ){
Lastitem = firstvisibleitem + visibleitemcount-1;
If (adapter. Count = lastitem ){
Adapter. Count + = 10;
Adapter. notifydatasetchanged ();
}
 
}
 
Public void onscrollstatechanged (abslistview view, int scrollstate ){
// Todo auto-generated method stub
 
Log. I ("onscrollstatechanged", "onscrollstatechanged ");
}
 

Public abstract void onscroll (abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount)
 
Since: API Level 1
 

Callback method to be invoked when the list or grid has been scrolled. This will be called after the scroll has completed
 

Parameters
 

View
 
The view whose scroll state is being reported
 

Firstvisibleitem
 
The index of the first visible cell (ignore if visibleitemcount = 0)

Visibleitemcount
 
The number of visible Cells
 
Totalitemcount
 
The number of items in the list adaptor

Public abstract void onscrollstatechanged (abslistview view, int scrollstate)
 
Since: API Level 1
 

Callback method to be invoked while the List View or grid view is being scrolled. if the view is being scrolled, this method will be called before the next frame of the scroll is rendered. in particle, it will be called before any calltogetview (INT, view,
Viewgroup ).
 

Parameters
 

View
 
The view whose scroll state is being reported
 

Scrollstate
 
The current scroll State. One of scroll_state_idle, scroll_state_touch_scroll orscroll_state_idle.

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.