1. Monitor ScrollView slide Stop:
[Java]View Plaincopy
- /******************** monitor ScrollView Slide Stop *****************************/
- Scrollview.setontouchlistener (new Ontouchlistener () {
- private int lasty = 0;
- private int toucheventid =-9983761;
- Handler Handler = new Handler () {
- @Override
- public void Handlemessage (Message msg) {
- super.handlemessage (msg);
- View scroller = (view) msg.obj;
- if (msg.what = = Toucheventid) {
- if (lasty = = scroller.getscrolly ()) {
- Handlestop (scroller);
- } Else {
- Handler.sendmessagedelayed (Handler.obtainmessage (Toucheventid, Scroller), 5);
- Lasty = scroller.getscrolly ();
- }
- }
- }
- };
- Public Boolean OnTouch (View V, motionevent event) {
- if (event.getaction () = = motionevent.action_up) {
- Handler.sendmessagedelayed (Handler.obtainmessage (Toucheventid, v), 5);
- }
- return false;
- }
- private void Handlestop (Object view) {
- ScrollView scroller = (ScrollView) view;
- scrolly = scroller.getscrolly ();
- }
- });
- /***********************************************************/
2. Monitor ScrollView slide to the bottom:
[Java]View Plaincopy
- Package Com.example.webviewdemo;
- Import Android.content.Context;
- Import Android.util.AttributeSet;
- Import Android.widget.ScrollView;
- Public class Scrollbottomscrollview extends ScrollView {
- private Scrollbottomlistener Scrollbottomlistener;
- Public Scrollbottomscrollview (context context) {
- super (context);
- }
- Public Scrollbottomscrollview (context context, AttributeSet attrs) {
- Super (context, attrs);
- }
- Public Scrollbottomscrollview (context context, AttributeSet attrs,int defstyle) {
- Super (context, attrs, Defstyle);
- }
- @Override
- protected void onscrollchanged (int L, int T, int OLDL, int Oldt) {
- if (t + getheight () >= Computeverticalscrollrange ()) {
- //scrollview slide to the bottom.
- Scrollbottomlistener.scrollbottom ();
- }
- }
- public void Setscrollbottomlistener (Scrollbottomlistener scrollbottomlistener) {
- This.scrollbottomlistener = Scrollbottomlistener;
- }
- public interface scrollbottomlistener{
- public void Scrollbottom ();
- }
- }
Android Monitor ScrollView slide stop and swipe to the bottom