0

I add a button in custom layout called listItem, which should have caused that the button could't get focus as the listItem overlay it according to the textbook. But the fact is that I can click the button while the list Item lose focus? I am confused.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:weightSum="1">

    <Button
        android:layout_width="69dp"
        android:layout_height="wrap_content"
        android:text="ok"
        android:id="@+id/button" />


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/itemTitle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="dsa"
            android:paddingLeft="15dp"
            android:paddingTop="3dp"
            android:textSize="20dp"/>

        <TextView
            android:id="@+id/itemText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="dsadsadas"
            android:paddingLeft="15dp"
            android:paddingBottom="3dp"
            android:layout_weight="0.20"
            android:textSize="12dp" />

    </LinearLayout>


</LinearLayout>
BP233
  • 85
  • 2
  • 9
  • try using this `android:descendantFocusability="blocksDescendants` fro the root element and do look @ http://stackoverflow.com/questions/15249632/android-custom-listview-with-imagebutton-is-not-getting-focus – Raghunandan Aug 01 '15 at 02:49
  • It works for me. Thanks! Now the button and listItem both get foucus. – BP233 Aug 01 '15 at 02:57

0 Answers0