. NET programmer play to Android Development---() ListView scrolling Event

Source: Internet
Author: User
Tags gettext

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

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.