Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final ImageView like = (ImageView) findViewById(R.id.like);
- //set the click listener
- like.setOnClickListener(new OnClickListener() {
- public void onClick(View button) {
- //Set the button's appearance
- button.setSelected(!button.isSelected());
- if (button.isSelected()) {
- like.setBackgroundDrawable(null);
- like.setBackgroundResource(R.drawable.starf);
- } else {
- like.setBackgroundResource(R.drawable.star);
- }
- }
- });
- <ImageView
- android:id="@+id/like"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_gravity="left"
- android:paddingLeft="10dp"
- android:paddingRight="40dp"
- android:background="@drawable/star"
- android:clickable="true" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement