Note that there are some explanatory texts on larger screens.

plurals
  1. POImage button change to press state when click item in listview in android
    text
    copied!<p>I have a list view with customize item, item in list view include: text view and image button, i have set background for image button with a selector. My problem is when i click on item in list view, image button change state to press (click event not trigger), i don't want to this, i want to image button change state to press only when i press on it. Any solution for me? Thanks!</p> <p>Layout of item row </p> <pre><code> &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="5dp" android:background="@drawable/song_list_selector" &gt; &lt;ToggleButton android:layout_width="wrap_content" android:layout_height="20dp" android:layout_alignParentLeft="true" android:background="@android:color/transparent" android:checked="true" android:textSize="12sp" android:textOn="@string/favorite" android:textOff="@string/favorite" android:textColor="@drawable/text_color_toggle_button" android:id="@+id/toggle_favorite" android:clickable="false" android:focusable="false"/&gt; &lt;ToggleButton android:layout_width="wrap_content" android:layout_height="20dp" android:layout_alignParentRight="true" android:background="@android:color/transparent" android:checked="false" android:textSize="12sp" android:textColor="@drawable/text_color_toggle_button" android:textOn="@string/offline" android:textOff="@string/online" android:id="@+id/toggle_offline" android:clickable="false" android:focusable="false"/&gt; &lt;ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_menu" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:padding="10dp" android:background="@drawable/bg_button_song_menu" android:contentDescription="@string/song_menu" android:id="@+id/btn_song_menu" android:focusable="false"/&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:layout_below="@id/toggle_favorite" android:layout_toLeftOf="@id/btn_song_menu" android:text="999 Doa Hong" android:textColor="#0e7491" android:textSize="20sp" android:id="@+id/lbl_song_name"/&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:text="Nhac chi chuyen xua, da xa roi nhu giac mo..." android:textSize="12sp" android:layout_below="@id/lbl_song_name" android:layout_toLeftOf="@id/btn_song_menu" android:id="@+id/lbl_song_lyric"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:drawableLeft="@drawable/ic_microphone" android:drawablePadding="2dp" android:textSize="12sp" android:text="1,478" android:layout_marginTop="5dp" android:layout_below="@id/lbl_song_lyric" android:id="@+id/lbl_sing_times"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:drawableLeft="@drawable/ic_save" android:drawablePadding="2dp" android:textSize="12sp" android:text="548" android:layout_marginTop="5dp" android:layout_below="@id/lbl_song_lyric" android:id="@+id/lbl_save_times"/&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Layout of listview</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".SongListActivity" &gt; &lt;ListView android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="3dp" android:paddingBottom="3dp" android:paddingLeft="0dp" android:paddingRight="0dp" android:divider="@null" android:listSelector="#00000000" android:cacheColorHint="#00000000" android:id="@+id/list_song"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12sp" android:textStyle="italic" android:id="@+id/lbl_no_song" android:layout_centerInParent="true" android:visibility="gone" android:textColor="#b6b6b6"/&gt; &lt;/RelativeLayout&gt; </code></pre>
 

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