mob*_*bob 41 events android gesture
Android支持onLongPress上的事件.我的问题是"多长时间"(以毫秒为单位)是触发事件的"按压"?
hac*_*bod 42
标准的长按时间是getLongPressTimeout()返回的,当前是500ms但可能会改变(在1.0中它是1000ms但在以后的版本中更改;可能在将来它将是用户可自定义的).
浏览器使用自己的长按时间,因为它有一些更复杂的交互.我相信这应该是1000,但将来可能会改变.它不是一起添加不同的超时.
小智 6
一般来说,就像Roman Nurik提到的那样,您可以使用ViewConfiguration.getLongPressTimeout()以编程方式获取长按值。默认值为 500 毫秒。
/**
* Defines the default duration in milliseconds before a press turns into
* a long press
*/
private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500;
Run Code Online (Sandbox Code Playgroud)
但是,可以通过将其设置为可访问性来全局自定义长按持续时间。值为短 (400 ms)、中 (1000 ms) 或长 (1500 ms)。您可以在“设置”中查看其源代码:
// Long press timeout.
mSelectLongPressTimeoutPreference =
(ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this);
if (mLongPressTimeoutValueToTitleMap.size() == 0) {
String[] timeoutValues = getResources().getStringArray(
R.array.long_press_timeout_selector_values);
mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]);
String[] timeoutTitles = getResources().getStringArray(
R.array.long_press_timeout_selector_titles);
final int timeoutValueCount = timeoutValues.length;
for (int i = 0; i < timeoutValueCount; i++) {
mLongPressTimeoutValueToTitleMap.put(timeoutValues[i], timeoutTitles[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28513 次 |
| 最近记录: |