How to get favorites star
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.
Some standard android images are available from the android sdk, which you can either browse on your computer on online here. (As CommonsWare said).
I also find this website super handy, as it shows me what each image looks like and tells me the name of the image so I can find it in the android sdk.