在我当前的 Android 应用程序中,我有一个MaterialCardView
包装了TextView
我希望可复制的,例如我使用
android:textIsSelectable="true"
但是,我还需要知道何时在项目布局MaterialCardView
中单击它。RecyclerView
我onClickListener
的 forMaterialCardView
仅在我android:textIsSelectable="true"
从 child 中删除属性时触发TextView
。
这是完整的 RecyclerView 项目布局
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_bibtext_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
card_view:cardBackgroundColor="?attr/colorSurface"
card_view:cardCornerRadius="10dp"
card_view:cardElevation="5dp"
card_view:cardPreventCornerOverlap="false"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="10dp">
<TextView
android:id="@+id/bibtex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textIsSelectable="true"
android:background="?android:attr/selectableItemBackground"
android:textColor="?android:attr/textColorPrimary" />
</com.google.android.material.card.MaterialCardView>
我怎样才能检测到对父母的点击MaterialCardView
并让孩子TextView
可选择?