I am using the ViewModel and Livedata. I tried getting the current position of ViewPager in ViewModel by using the following code
<android.support.v4.view.ViewPager
android:id="@+id/moveFromPlansViewPager"
android:layout_width="0dp"
android:layout_height="72dp"
android:layout_marginTop="16dp"
android:clipToPadding="false"
android:selectedItemPosition="@={ viewModel.selectedPos }"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/moveFromHeaderTextView" />
Inside ViewModel I have
var selectedPos: MutableLiveData<Int> = MutableLiveData()
And I find the value in selected position and compare it with the value in EditText. Somehow I think this logic is correct. But the problem is while
android:selectedItemPosition="@={ viewModel.selectedPos }"
When I add this line to the layout it causes databinding error.
e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found databinding errors.
Can anybody help me???