I have a RecyclerView with the following items layout:
<LinearLayout
android:orientation="horizontal"
....
android:clickable="@{viewModel.isClickable}"
android:onClick="@{viewModel::onPropertyClicked}">
<LinearLayout
....
android:clickable="false">
<TextView
android:clickable="false"
android:focusable="false"
.... />
<EditText
...
android:text="@{viewModel.propertyValue}"
android:focusable="@{viewModel.isEditTextClickable}"
android:focusableInTouchMode="@{viewModel.isEditTextClickable}"
android:cursorVisible="@{viewModel.isEditTextClickable}"
android:clickable="@{!viewModel.isEditTextClickable}"/>
</LinearLayout>
<ImageView ... />
</LinearLayout>
I want depending on a boolean the EditText
to be either editable
or non-editable and clickable
. For some unknown reason, my EditText
doesn't dispatch the touch event to the parent's parent. If I click on the TextView
though, the onClick
method is called.
If I specify the onClick
of the EditText
it works. I am wondering why though it doesn't work through the root ViewGroup's onClick
.
I have tried many different things like
EditText
using inputType
EditText
is non-editable and clickable set focusable to false and clickable to true EditText
using enabled
true/false It's really weird because the EditText
is actually almost the same as the TextView
that behaves as expected.
Any ideas?
try to change this android:clickable="@{!viewModel.isEditTextClickable}"/>
for android:clickable="@{viewModel.isEditTextClickable}"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.