Niwla23
Niwla23

Reputation: 113

How to handle SwipeRefreshLayout on refresh?

I want to reload a page with Kotlin when the swipe refresh button is pulled down. I cant find any tutorials on this for Kotlin. This gives me a datatype mismatch, how to do it right?

swipe_container.setOnRefreshListener { view ->
    webview1.loadUrl("https://google.com/")
}

Upvotes: 0

Views: 113

Answers (2)

Omkar C.
Omkar C.

Reputation: 751

Datatype mismatch could be because you're trying to pass view inside setOnrefreshListener.

swipe_container.setOnRefreshListener {
    webview1.loadUrl("https://google.com/")
}

This should work for you, i'd also suggest to checkout this page for an example on implementing swipe refresh functionality on your page.

Upvotes: 1

Ryan M
Ryan M

Reputation: 20147

OnRefreshListener doesn't pass a view parameter - your code should be

swipe_container.setOnRefreshListener {
    webview1.loadUrl("https://google.com/")
}

Upvotes: 2

Related Questions