默认微调行为是当它的封闭,它长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的数据?它来、服务器、数据、如何在
下一篇:实现IDataErrorInfo使用NHibernate的延迟加载情况下使用Castle.DynamicProxy情况下、加载、NHibernate、IDataErrorInfo