How to attach OnScrollListener to a ListView

14 views
Skip to first unread message

ales

unread,
Apr 26, 2016, 2:57:09 AM4/26/16
to macroid
Hi,
I am trying to use Macroid to attach OnScrollListener to a ListView:

w[ListView] <~ FuncOn.scroll[ListView] {
   
(view: AdapterView[_], first: Int, visCount: Int, totalCount: Int) =>
     
println("doing something")
}

but of course this causes this error message to be thrown on compile time:

object creation impossible, since method onScrollStateChanged in trait OnScrollListener of type (x$1: android.widget.AbsListView, x$2: Int)Unit is not defined.

It there a macroid technique to avoid this message (e.g. define empty onScrollStateChanged method)?

Thank you for any hint
Ales

ales

unread,
Apr 26, 2016, 3:16:16 AM4/26/16
to macroid
Actually I did the following, but little bit more verbose solution:

w[ListView] <~ Tweak[ListView] { l =>
   l.setOnScrollListener(new OnScrollListener {
     
override def onScroll( absListView: AbsListView, first: Int, visCount: Int, totalCount: Int ): Unit = {
         
println(s"Scroll: $first, $visCount, $totalCount")
     
}
     
override def onScrollStateChanged( absListView: AbsListView, i: Int ): Unit = {
         
println(s"ScrollStateChanged: $i")
     
}
   
})


Reply all
Reply to author
Forward
0 new messages