私は、リストビューのアイテムが(複雑なレイアウトであっても)問題なくonpressイベント(押された状態と押されなかった状態にするいくつかのアクション)を処理するという事実に慣れています。しかし今、私はLinearLayoutから同じものが欲しいです-とにかくレイアウトを押すと、すべての子孫がonpressイベントを取得するはずです。
これは私のフラグメントレイアウトの一部であり、プレスイベントで強調表示する必要があります。
<LinearLayout
android:id="@+id/ll_about_fragment_feedback"
android:gravity="center_vertical"
android:layout_height="54dp"
android:background="@drawable/about_item_bkg"
android:layout_width="match_parent">
<ImageView
android:layout_height="wrap_content"
android:background="@drawable/about_item_feedback_icon"
android:layout_width="wrap_content"
android:layout_marginLeft="11dp"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/about_fragment_feedback"
android:layout_marginLeft="14dp"
android:textSize="16dp"
android:textColor="@drawable/about_item_textcolor"/>
</LinearLayout>
ルートレイアウトの背景はプレス時に変更されますが、子孫のテキストカラーは変更されません。ルートからイベントを取得していないようです。
それで、あなたは助けることができますか?
更新:LinearLayout ll_about_fragment_feedbackはOnClickListenerをバインドしており、selecrorsにはすべて問題ありません