I have a requirement where I need to implement a thumbs up, thumbs down type of toggle button and I am struggling here to perceive how to accomplish this.
I am not sure if I could create a style and this style would have a where it would change the background of the image depending of how the button is pressed….
Anyone could share some ideas?
Regards,
Felipe
UPDATE:
Hey guys
Following the ideas given here, I implemented the following code:
tglBtnThumbsUp.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tglBtnThumbsDown.setChecked(false);
tglBtnThumbsUp.setChecked(true);
}
});
tglBtnThumbsDown.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tglBtnThumbsUp.setChecked(false);
tglBtnThumbsDown.setChecked(true);
}
});
It works just the way I want.
Now, trying to find a “thumbs up” and “thumbs down” PSD files in the Internet so I can change the background, as I am a very very very bad designer and can’t do myself
Thanks to everyone!
Do you mean two toggle buttons side-by-side where the user turns one of them on, or do you mean one toggle that goes either up or down?
For just one togglebutton, use a selector in XML with the picture of an up thumb and a down thumb as state_checked=”true” or false respectively. Otherwise put two different toggle buttons side by side, and have one of them light up or not at a time with OnCheckedChangeListener.
Hope that made sense.