The source code to the Contacts application is available online, since Android is open source.
Some poking around in there will lead you to the contact_header.xml
file, found in your SDK installation. It indicates that the star is implemented via a CheckBox
:
<CheckBox
android:id="@+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:visibility="gone"
android:contentDescription="@string/description_star"
style="?android:attr/starStyle" />
That, in turn, routes you to an entry in a theme:
<item name="starStyle">@android:style/Widget.CompoundButton.Star</item>
which in turn resolves to:
<style name="Widget.CompoundButton.Star">
<item name="android:background">@android:drawable/btn_star_label_background</item>
<item name="android:button">@android:drawable/btn_star</item>
</style>
So, use those images with a CheckBox
, and you should get the same behavior. Those images are also available in your SDK installation.