Click in a ListView item changes status of elements inside the item?

Posted by Antonio on Stack Overflow See other posts from Stack Overflow or by Antonio
Published on 2010-04-09T13:15:01Z Indexed on 2010/04/09 14:03 UTC
Read the original article Hit count: 656

Filed under:
|
|
|
|

Hi,

I don't know exactly how to explain this problem, but I'll try. I have a ListView with several items. Each item has inside a TextView and two ImageView. I want the ImageView change when I click on them, and I want to open a context menu when I press for a long time into the ListView item.

For the ImageView, everything works properly. For the whole item, I can show the context menu after a long press, but my problem is that the ImageView changes as well when I am pressing the TextView, for example.

Somo pieces of my code:

ListView item:

     <TextView 
      android:id="@+id/title"
      android:textColor="@color/black"
      android:maxLines="2"
      android:textSize="14dip" 
            />
    <ImageView
        android:id="@+id/minus"
        android:src="@drawable/minusbutton"
        android:adjustViewBounds="true"
        android:gravity="center"
    />
    <ImageView 
        android:id="@+id/plus"
        android:src="@drawable/plusbutton"
        android:adjustViewBounds="true"
        android:gravity="center"
    />

Drawable to change the status of the plus button:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
      android:drawable="@drawable/button_add_normal_disabled" />
<item android:state_enabled="true"
      android:state_pressed="true"
      android:drawable="@drawable/button_add_pressed" />
<item android:state_enabled="true"
      android:state_focused="true" 
      android:state_pressed="false" 
      android:drawable="@drawable/button_add_active" />
<item android:state_enabled="true"
      android:state_focused="false" 
      android:state_pressed="false"
      android:drawable="@drawable/button_add_normal" />

I hope you understand my problem. I think that all the children of a view are affected by an event in the parent, but I am not sure.

Do you have a solution? Thanks in advance

© Stack Overflow or respective owner

Related posts about android

Related posts about listview