RxTextView and other widgets not found while using latest com.jakewharton.rxbinding3:rxbinding:3.0.0-alpha2 library
Asked Answered
U

1

12

I wanna use RxJava binding APIs for Android UI widgets in my project.

Therefore following the guidance as per this site 'https://github.com/JakeWharton/RxBinding'

But I am unable to import any Android UI widgets in my Kotlin File. Where as its working fine if I am consuming these widgets in Java File. Hence, not been to find the actual of this issue.

For reference following are the gradle file and class files(both kotlin and java) using in same project

build.gradle

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.core:core-ktx:1.2.0-alpha01'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.8'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    //RxBinding
    implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0-alpha2'
}

BindingExample.java class

enter image description here

RxBindingExample.kt class

enter image description here

Have tried exploring this issue on S.O. but questions or solutions are available for previous version of lib 'com.jakewharton.rxbinding2:rxbinding'

Updo answered 28/5, 2019 at 9:4 Comment(2)
Have you tried to add the same import from the first example manually?Unalterable
@LucianoFerruzzi : Yes I tried that as well but showed the same error 'Unresolved reference:RxTextView' at import line.Updo
U
18

Check this reference: https://github.com/JakeWharton/RxBinding/blob/master/rxbinding/src/main/java/com/jakewharton/rxbinding3/widget/TextViewTextChangeEventObservable.kt

There are different ways to use depending on the language, note the @file:JvmName("RxTextView") at the start. If you're using java the class RxTextView is visible, in kotlin you should use the extension functions provided by the lib, textChangeEvents() is an example of it.

like that, this will aquire the observable e.g.:

val someTextView = TextView(context)
someTextView.textChangeEvents()

Edit:

Seems that the old class that I've referenced was deleted, here is another one: https://github.com/JakeWharton/RxBinding/blob/master/rxbinding/src/main/java/com/jakewharton/rxbinding4/widget/TextViewAfterTextChangeEventObservable.kt

Unalterable answered 28/5, 2019 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.