用2- seekbars在相同的活性 [英] using 2 seekbars in the same activity

查看:156
本文介绍了用2- seekbars在相同的活性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2 seekbars A和B,我有2 textviews C和感动,当一个D.编辑C的价值和感动当B编辑D的值。我的code正常工作。不过,我当用户使用搜索栏,然后B变为残疾人,同样当正在使用的用户将一个SeekBar B成为残疾人希望它这样。在seekbars成为undisabled的方法是,当用户点击它再次使用它。所以,如果我使用搜索栏A则B,如果我感动了搜索栏B检查将启用,那么A将被禁用会被禁用,然后。或者即使它彪改变seekbars颜色,是目前以浅灰色蓝色给它被禁用会也许另一种方式的错觉。纽威我想这一点。
 为搜索栏A

I have 2 seekbars A and B and i have 2 textviews C and D. A edits the value of C when moved and B edits the value of D when moved. My code works fine. However I want it so that when the user is using A then seekbar B becomes disabled and likewise when seekbar B is being used by the user A becomes disabled. The way the seekbars become undisabled is when a user clicks on it to use it again. So if i were using seekbar A then B would be disabled then if i touched seekbar B it would be enabled and then A would be disabled. Or even if it ment changing the seekbars colour which is blue at the moment to a light grey colour to give the illusion that it is disabled would be another way perhaps. Neway i tried this. for seekbar A

        @Override
        public void onStartTrackingTouch(SeekBar seekbar) {
            // TODO Auto-generated method stub

             seekbarB.setEnabled(false);
             seekbarA.setEnabled(true);
        }
        @Override
        public void onStopTrackingTouch(SeekBar seekbar) {
            // TODO Auto-generated method stub
             seekbarB.setEnabled(true);
             seekbarA.setEnabled(true);
        }

和搜索栏乙

@Override
        public void onStartTrackingTouch(SeekBar seekbar) {
            // TODO Auto-generated method stub
             seekbarB.setEnabled(true);
             //seekbarA.setEnabled(false);

        }
        @Override
        public void onStopTrackingTouch(SeekBar seekbar) {
            // TODO Auto-generated method stub
             seekbarB.setEnabled(true);
             seekbarA.setEnabled(true);
        }

但是,无论这样的工作,但那么当用户使用任一seekbars的已被禁用再次成为启用了其中一个我没有想,除非用户碰过它停止。现在我知道你的想法不设置seekbars在onstoptrackingtouch启用。嗯,我试过了,而且被禁用永远不会成为搜索栏启动后,即使你摸到了我,甚至实现了一个ontouchlistener每个搜索栏,看它是否会成为活跃,但它没有。
所以我有你们帮助我的三种方式。
1.是否存在编辑上面我的方法一种方式来获得它的工作就是我想要的?
2.我在哪里可以把我让搜索栏的方法,这样,当用户触摸它从而实现我上述的搜索栏才会有效?
3.有没有办法来改变Java中的自定义seekbars颜色来达到我想要的。

but however this kind of worked but then when the user stopped using either of the seekbars the one that had been disabled became enabled again which I didnt want unless the user touched it. Now i know what your thinking dont set the seekbars to enabled in the onstoptrackingtouch. Well i tried that and the seekbar that was disabled would never become enabled even if you touched it i even implemented an ontouchlistener for each seekbar to see if it would become active but it didnt. so i have three ways of you guys helping me. 1. Is there a way to edit my method above to get it working the way i want? 2. Where can i put my enable seekbar method so that the seekbar only becomes active when the user touches it thus achieving what i stated above? 3. Is there a way to change a custom seekbars colours in java to achieve what i want

推荐答案

您可以尝试以下方法:把搜索栏布局的包裹搜索栏,把一个 OnTouchListener 布局,然后重新启用搜索栏当用户触摸布局

You could try the following: put the SeekBar in a Layout that wrap the SeekBar and put a OnTouchListener on the Layout, then re-enable the SeekBar when the user touches the Layout.

搜索栏不能轻易AFAIK改变(你需要创建有色资源,看到的本网站产生这样resouces)。

The color of the SeekBar cannot be easily changed afaik (you need to create colored resources, see this site to generate such resouces).

如果你想传达给他只能使用一个搜索栏在一个时间用户,我想,而不是使用

If you want to communicate to the user that he can only use one SeekBar at a time, I would, instead of using

seekbar.setEnabled(false)

只是减少的搜索栏α,使得它苍白。使用 seekBar.setAlpha()或者,如果你想针对API级别< 11,使用这个库的视图助手类。

just reduce the alpha of the SeekBar, making it 'pale'. Use seekBar.setAlpha() or, if you want to target API levels < 11, use this library's ViewHelper class.

这篇关于用2- seekbars在相同的活性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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