У меня возникла странная проблема. Я добавил пользовательскую строку в свой ListView, когда я удаляю строку Button, можно выбрать, но по мере добавления кнопки я не могу щелкнуть строки, см. xml ниже.Android ListView с кнопкой нельзя выбрать (можно кликнуть)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="77dp"
android:layout_height="77dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:src="@drawable/company_logo" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Idds sdsad "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imageView1"
android:layout_below="@+id/textView1"
android:textColor="#8b8989"
android:layout_marginLeft="5dp"
android:text="Tap to see detail"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true"
android:text="Button" />
Пожалуйста, помогите, почему это происходит.
установка android: descendantFocusability = "blocksDescendants" в контейнере макета строки была достаточной для решения этой проблемы для меня. Я не должен был ничего делать с фокусным свойством кнопки. – harmanjd
Даже лучшее решение, так как оно более декларативное и высокоуровневое. Очень хорошо. – Marchy