The ListView in Android can swipe up and down, and the up and down activities can load data in pages, which we'll look at in the ListView scrolling event.
The scroll events of the ListView are mainly implemented by the Setonscrolllistener listener, which consists of two methods Onscroll and Onscrollstatechanged methods, Onscrollstatechanged is mainly used to monitor the scrolling state
Adding data to the ListView during sliding, the ListView scrolls with three states, Scroll_state_touch_scroll, Scroll_state_fling,scroll_state_idle
Lv.setonitemclicklistener (New Onitemclicklistener () {@Override public void Onitemclick (adapte rview<?> arg0,view arg1, int arg2, long arg3) {TextView TNA Me= (TextView) Arg1.findviewbyid (r.id.tvname);//Name TextView tmodel= (TextView) Arg1.findviewbyid (R.id.tvmodel );//Specification TextView tprice= (TextView) Arg1.findviewbyid (r.id.tvprice);//Unit Price TextView tcode= (Textvie W) Arg1.findviewbyid (R.id.tvcode);//Code Toast.maketext (Getapplicationcontext (), "Current product Name:" +tname.gettext () + ", Code:" +tcode.gettext (), (). Show (); } }); Lv.setonscrolllistener (New Onscrolllistener () {@Overridepublic void onscroll (Abslistview arg0, int arg1, int arg2,int ARG3) {//Todo auto-generated method stub} @Overridepublic void Onscrollstatechanged (Abslistview arg0, int arg1) {//Todo A uto-generated method Stub scroll State listener if (Arg1==abslistview.onscrolllistener.scRoll_state_touch_scroll) {//finger does not leave the screen, is sliding toast.maketext (Getapplicationcontext (), "finger does not leave the screen, is sliding", "). Show (); Map<string,object> map=new hashmap<string,object> (); Map.put ("Code", "code: 10"); Map.put ("name", "title: Ipad"); Map.put ("Prices", "Price: 22"); Map.put ("Model", "unit: 22"); Maplist.add (map); Adp.notifydatasetchanged (); Simpleadapter Sadapter = (simpleadapter) lv.getadapter (); Sadapter.notifydatasetchanged (); }else if (arg1==abslistview.onscrolllistener.scroll_state_fling) {//finger before leaving the screen, swipe a bit toast.maketext ( Getapplicationcontext (), "swipe your finger before you leave the screen," (). Show (); }else if (arg1==abslistview.onscrolllistener.scroll_state_idle) {//Stop sliding Toast.maketext (Getapplicationcontext (), " Stop Sliding "," (). Show (); }} });
. NET programmer play to Android Development---() ListView scrolling Event