Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent Button inside ListItem getting highlight
    primarykey
    data
    text
    <p>So I have custom list item with buttons for a ListView. When pressed, the button display alternate drawable to show feedback to user. However when I click on the row, every buttons show pressed state as if I have clicked on them.</p> <p>How do I keep the button displays its original state instead of state_pressed?</p> <p>layout/List Item:</p> <pre><code>&lt;LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:orientation="horizontal" android:paddingBottom="10dp" android:paddingTop="10dp" android:descendantFocusability="blocksDescendants" &gt; &lt;LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" android:paddingLeft="10dp" android:paddingRight="10dp" android:gravity="center_vertical|left" &gt; &lt;TextView android:id="@+id/txtMain" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/PrimaryText" /&gt; &lt;TextView android:id="@+id/txtSub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/SecondaryText" /&gt; &lt;/LinearLayout&gt; &lt;ImageButton android:id="@+id/imbResponse" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@null" android:focusable="false" android:duplicateParentState="false" android:src="@drawable/response_btn" android:contentDescription="@string/response" android:layout_marginLeft="10dp" android:layout_marginTop="5dp" android:layout_marginRight="10dp" android:layout_marginBottom="5dp" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>drawable/response_btn.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;selector xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:state_focused="true" android:drawable="@drawable/res_m" /&gt; &lt;item android:state_pressed="true" android:drawable="@drawable/res_m" /&gt; &lt;item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/res_alt_m" /&gt; &lt;/selector&gt; </code></pre> <p>I have tried to remove state_focused and state_pressed, state_focused. It seems that the button take state_pressed from its parent.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload