How to change spinner selection value by scrolling listview in android -


i want change value selection of spinner when listview scroll user. have no idea how example great help.

the spinner has list of item such 1 2 3 4 5 6 7 8 9 10...

and listview has verse number text

  1. text in listview
  2. text in listview
  3. text in listview
  4. text in listview
  5. text in listview

so, when listview scroll, want spinner item number change. when listview has (2. text in listview) @ top screen spinner item change 2

what understood question want update spinner first visible item's position of listview while scrolling. need implement onscrolllistener listview:

listview.setonscrolllistener(new abslistview.onscrolllistener() {             @override             public void onscrollstatechanged(abslistview abslistview, int i) {              }              @override             public void onscroll(abslistview abslistview, int firstvisibleitem, int visibleitemcount, int totalitemcount) {                   //here can first visible item position , can update spinner respectively.                   spinner.setselection(firstvisibleitem);               }         });  

you can see, when implement onscrolllistener, overrides 2 methods onscrollstatechanged , onscroll. , in onscroll method firstvisibleitem's position , hence can update spinner well.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -