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.