如何实现"大拇指向下/竖起大拇指"在Android的切换按钮 [英] Ways to implement a "Thumbs down/Thumbs up" toggle button in Android

查看:178
本文介绍了如何实现"大拇指向下/竖起大拇指"在Android的切换按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我需要实现一个竖起大拇指的要求,拇指向下切换按钮的类型,我奋力这里感觉如何做到这一点。
我不知道我是否能创建一个风格,这种风格将有哪里会根据的按钮是如何pssed $ P $改变图像的背景....

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

更新:

嘿,伙计们
继这里给出的想法,我采取了以下code:

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);

        }
    });

它的工作原理只是我想要的方式。
现在,试图找到一个好与不好的互联网PSD文件,所以我可以改变的背景下,因为我是一个非常非常非常糟糕的设计师,不能做我自己

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

谢谢大家!

推荐答案

你意味着两切换按钮并排侧,用户打开他们中的一个,还是你指的是一个拨动了去向上或向下?

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?

有关只有一个切换按钮,以XML使用选择带有向上拇指的画面和向下拇指分别state_checked =true或假。否则,把两个不同的切换按钮并排,并有其中之一亮或没有与OnCheckedChangeListener时间。

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.

希望这是有道理的。

这篇关于如何实现"大拇指向下/竖起大拇指"在Android的切换按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆