在Android上,有没有什么办法来禁用一个微调的长期preSS行为?有没有什么、行为、办法、Android

2023-09-06 07:30:57 作者:亲爱的自己,现在的付出,都会是一种沉淀,它们会默默铺路,只为

默认微调行为是当它的封闭,它长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();
            }

        });
 
精彩推荐
图片推荐