在Android上,有没有什么办法来禁用一个微调的长期preSS行为? [英] On Android, is there any way to disable a Spinner's long-press behavior?

查看:141
本文介绍了在Android上,有没有什么办法来禁用一个微调的长期preSS行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认微调行为是当它的封闭,它长pressing将开放,并出示您的下拉视图。我觉得这种行为是对潜在用户很成问题。举例来说,如果他们试图滚动屏幕上的内容,而发生抢,有一个微调,然后代替滚动一个点,它会打开之后一秒钟左右的下拉列表视图,用户基本上留下了他们的手指上的下拉选项之一(他们现在可以意外preSS)。

The default spinner behavior is that when it's "closed", longpressing on it will "open" it and show you the dropdown view. I find this behavior to be potentially very problematic for the user. For example, if they're trying to scroll something on the screen, and happen to "grab" a spot that has a spinner, then instead of scrolling, it'll open the dropdown view after a second or so, and the user is basically left with their finger on one of the dropdown options (which they can now accidentally press).

所以,我想禁用长期preSS的行为,并微调开放它的点击,只有当,而不是长期pressed。这可能吗?

So, I'd like to disable that long-press behavior, and have the spinner "open" when only it's clicked, and not long-pressed. Is that possible?

推荐答案

所以,我想出了一个相对简单的方式做到这一点,即使它不是很优雅。基本上,我创建的微调顶部的透明覆盖图,并将其设置为有,只是触发微调的点击一个OnClickListener。

So, I've figured out a relatively easy way to do this, even though it's not very elegant. Basically, I created a transparent overlay view on top of the Spinner, and set it to have an OnClickListener that just triggers a Spinner's click.

XML:

    <Spinner 
        android:id="@+id/spinner"
        android:layout_width="match_parent" 
        android:layout_height="40dip" />

    <View android:id="@+id/spinner_overlay"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_alignLeft="@id/spinner" 
        android:layout_alignRight="@id/spinner"
        android:layout_alignTop="@id/spinner" 
        android:layout_alignBottom="@id/spinner"  />

Java的:

        View spinnerOverlay = findViewById(R.id.spinner_overlay);
        spinnerOverlay.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                spinner.performClick();
            }

        });

这篇关于在Android上,有没有什么办法来禁用一个微调的长期preSS行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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