Android Monitor ScrollView swipe to the bottom.

Source: Internet
Author: User

When making a product, there is a need to monitor the ScrollView slide to the bottom. On the Internet to find some methods, there are such or that the problem, or the monitoring is not accurate,

Or the repetitive monitoring, the code is not product, very unreliable.

After their own experiments, finally found a capable of accurate monitoring of the implementation method. The code is as follows:

1  Public classScrollbottomscrollviewextendsScrollView {2 3     PrivateOnscrollbottomlistener _listener;4     Private int_calcount;5 6      Public InterfaceOnscrollbottomlistener {7         voidSrolltobottom ();8     }9 Ten      Public voidRegisteronscrollviewscrolltobottom (Onscrollbottomlistener l) { One_listener =l; A     } -  -      Public voidUnregisteronscrollviewscrolltobottom () { the_listener =NULL; -     } -  -      PublicScrollbottomscrollview (Context context, AttributeSet attrs) { +         Super(context, attrs); -     } +  A @Override at     protected voidOnscrollchanged (intLintTintOLDL,intOldt) { -View view = This. Getchildat (0); -         if( This. GetHeight () + This. getscrolly () = =view.getheight ()) { -_calcount++; -             if(_calcount = = 1) { -                 if(_listener! =NULL) { in _listener.srolltobottom (); -                 } to             } +}Else { -_calcount = 0; the         } *     } $}

The product used in this code is also tested on-line, no bugs.

The Android SDK is similar to such imperfect countless, such as Ontouch event delivery, Onmeasure method calls, are very imprecise,

Need to optimize their own, no way, unable to spit groove.

Android Monitor ScrollView swipe to the bottom.

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.