Replace checkbox with a star image to emphasise it in Android app -
i have list view page in android application each row contains/displays text, date , checkbox.
if checkbox selected, means particular row in list important. want replace checkbox star image indicate row important. list page code follows:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background_activated"> <checkbox android:id="@+id/note_list_item_solvedcheckbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:layout_alignparentright="true" android:enabled="false" android:focusable="false" android:padding="4dp" /> <textview android:id="@+id/note_list_item_titletextview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toleftof="@id/note_list_item_solvedcheckbox" android:textstyle="bold" android:paddingleft="4dp" android:paddingright="4dp" android:text="note title" /> <textview android:id="@+id/note_list_item_datetextview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/note_list_item_titletextview" android:layout_toleftof="@id/note_list_item_solvedcheckbox" android:paddingleft="4dp" android:paddingright="4dp" android:paddingtop="4dp" /> </relativelayout>
can give me code replace checkbox star image?
lucky made this, create selector in drawable such:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:drawable="@drawable/star_checked" /> <item android:state_pressed="true" android:drawable="@drawable/star_checked" /> <item android:drawable="@drawable/star_unchecked" /> </selector>
and checkbox
:
<checkbox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/checkboxfavourite" android:button="@drawable/selector_checkbox" <!-- important line --> android:gravity="center" android:layout_marginleft="10dp" android:focusable="false" android:focusableintouchmode="false"/>
Comments
Post a Comment