OnClickListener onClick=true and selector

Posted by azerto00 on Stack Overflow See other posts from Stack Overflow or by azerto00
Published on 2012-10-20T22:53:52Z Indexed on 2012/10/20 23:00 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

I have not found any answer for my problem, so I need your help ... I have an LinearLayout which I want to be clickable in order to lunch another activity. So I implement an onClickListener to it. I created an selector for this LinearLayout in order that what someone click on it, the background change.

I just don't understand that :

  • If my LinearLayout doesn't have android:clickable="true" in the xml, I'm able to click on it and get what I want but the selector doesn't work.
  • If I remove this line, it is the opposite .. the selector work but not the onClick event.

So, can anyone can explain me why ? Just in case, here is my the content of my selector file :

<selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:drawable="@drawable/btn_restaurants_background_state_pressed" android:state_pressed="true"></item>
   <item android:drawable="@drawable/btn_restaurants_background_state_pressed" android:state_focused="true"></item>
   <item android:drawable="@drawable/btn_restaurants_background_state_pressed" android:state_selected="true"></item>
   <item android:drawable="@drawable/btn_restaurants_background_state_normal"></item>
</selector>

Thanks you in advance

© Stack Overflow or respective owner

Related posts about java

Related posts about android