Arunachalam k
Arunachalam k

Reputation: 744

RecyclerView adapterPosition is deprecated and Gradle throwing error as Could not find accessor bindingAdapterPosition

In the latest Gradle plugin When I try to access the adapter position field IDE showing as deprecated. Suggesting to use getBindingAdapterPosition() instead of adapterPosition

But When I try to access the field getBindingAdapterPosition() IDE is throwing error as

Could not find accessor com.rizek.android.users.adapters.recyclerview.cart.ProductListAdapter.ExpandViewHolder.bindingAdapterPosition

My XML File :

        <ImageView
        android:id="@+id/imageView14"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:onClick="@{()->frequencyOptionInteractor.onRecurringOptionChanged(recurringViewHolder.adapterPosition,frequencyOption)}"
        android:padding="8dp"
        app:layout_constraintBottom_toBottomOf="@+id/linearLayout12"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@+id/linearLayout12"
        app:srcCompat="@drawable/frequency_option_selector"
        bind:stateActivated="@{frequencyOptionAdapter.selectedPosition==recurringViewHolder.bindingAdapterPosition}" />

Upvotes: 4

Views: 2053

Answers (2)

Hitesh Sahu
Hitesh Sahu

Reputation: 45100

If you are using ViewPager2 make sure to add it as dependency.

implementation "androidx.viewpager2:viewpager2:1.0.0"

Upvotes: 0

user2424380
user2424380

Reputation: 1473

If you haven't done it yet, you can try to add RecyclerView manually to your

build.gradle 

file (module) :

// RecyclerView
implementation "androidx.recyclerview:recyclerview:1.2.0"

This worked for me.

Upvotes: 5

Related Questions