i want have imagebuttons changing image based on state. (same "like" button in 9 gag , facebook apps).
i have defined style each of them references selector drawable when run program, images doesn't appear. can tell me what's wrong approach? (sorry bad english)
comment_actions_style in values folder:
<style name="likestyle"> <item name="android:src">@drawable/like</item> </style> <style name="dislikestyle"> <item name="android:src">@drawable/dislike_normal</item> </style> <style name="replystyle"> <item name="android:src">@drawable/reply_normal</item> </style> <style name="sharestyle"> <item name="android:src">@drawable/share</item> </style> </resources> and drawable in drawable folder: (other buttons same)
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/like_clicked" android:state_pressed="true"/> <!-- pressed --> <item android:drawable="@drawable/like_focused" android:state_focused="true"/> <!-- focused --> <item android:drawable="@drawable/like_normal"/> <!-- default --> </selector> edit:
forgot mention, have list view items user comments , comments have buttons described above.
here items layout (part of it)
<linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/comment_content" android:orientation="horizontal" > <include android:id="@+id/like" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" layout="@layout/comment_actions" style="@style/likestyle" /> </linearlayout> and comment_actions layout:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/comment_action" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingbottom="5dip"> <imagebutton android:id="@+id/comment_action_img" android:layout_width="40dp" android:layout_height="40dp" android:background="@android:color/transparent" /> <textview android:id="@+id/comment_action_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_torightof="@id/comment_action_img" android:gravity="center" android:layout_marginleft="5dip"/> </relativelayout> these buttons inherit layout if that's matter.
here, setting style comment_actions layout, , relative layout, won't abled response "android:src" attribute.
<linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/comment_content" android:orientation="horizontal" > <include android:id="@+id/like" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" layout="@layout/comment_actions" style="@style/likestyle" /> <!--here,you setting style relativelayout --> </linearlayout>
Comments
Post a Comment