Manoj Perumarath
Manoj Perumarath

Reputation: 10214

RxSearchView not supporting androidx SearchView?

I've migrated my project to androidx. When i use RxSearchView it results in an error

RxSearchView.queryTextChanges(searchView).

Type mismatch. Required: android.widget.SearchView

Found:

androidx.appcompat.widget.SearchView

Upvotes: 2

Views: 1349

Answers (2)

Ovi Trif
Ovi Trif

Reputation: 401

If you update your dependency to the rxbinding3, version 3.0.0 by adding the following line in your app's build.gradle:

implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0'

Then you should be fine by simply using the new API adapted to the Kotlin style:

Replace your code where it has

RxSearchView.queryTextChangeEvents(searchView)

to

searchView.queryTextChangeEvents()

Also keep in mind that the return value typed as SearchViewQueryTextEvent uses property access, so things like it.queryText() should be changed to it.queryText.

Upvotes: 1

pamobo0609
pamobo0609

Reputation: 812


I was facing this problem recently and was able to fix it by using this explicit dependency: implementation 'com.jakewharton.rxbinding3:rxbinding-appcompat:3.0.0-alpha2'.

You can find this dependency and some other ones at Github RxBinding.

I hope I was not too late and I hope this helps!

Edit
I know I responded this not long ago but something messed up the library. 3.0.0-alpha is no longer the latest release and has been replaced with version 3.0.0 of which I no longer find RxSearchView anywhere, not even on the alpha version.


Edit 2
Since I never found RxSearchView again, I had to implement an OnQueryTextListener myself, following a pretty cool tutorial I found here. It uses Kotlin's new coroutines and works as fine as RxSearchview.

Upvotes: 2

Related Questions