2009-12-18 22 views

回答

36

標準長按時間是getLongPressTimeout()返回的值,它目前爲500毫秒,但可能會更改(1.0版本中爲1000毫秒,但在以後的版本中有所變化;將來可能會由用戶自定義)。

瀏覽器使用它自己的長按時間,因爲它有一些更復雜的相互作用。我相信這應該是1000,儘管它未來可能會改變。它不會將不同的超時加在一起。

+0

你確定這件事嗎?我的觀察結果是在網絡瀏覽器上1650毫秒(1750毫秒以確定其他處理負載)。你可以網站一些實驗室筆記或Android文檔? – mobibob 2009-12-22 23:08:22

+0

..另外,查看源代碼,LONG時間直到檢測到短按之後纔開始其時間測量。這就是爲什麼我認爲這是累積在國家。 我不是在挑戰你的陳述,只是討論確定答案是徹底的,我的問題不會被誤解。 – mobibob 2009-12-22 23:12:34

+0

不幸的是(對我來說)這是我的問題唯一正確的答案。但是......我真正想學的是從按下開始到瀏覽器彈出「解析器」對話框的時間。我測量1.650秒,所以我想找到缺少的650毫秒。我會將答案授予hackbod,並感謝所有人的評論。 – mobibob 2009-12-27 04:20:31

17

您可以使用android.view.ViewConfigurationgetLongPressTimeout方法以編程方式確定該值。

詳見the docs

1

嗯...我希望得到的累計時間。據我所知,getLongPressTimeout(),是確定事件按下時添加的組件時間加上TAP_TIMEOUT加上???如果在網頁瀏覽器中則爲1000毫秒。

我已經計算出它是1650ms,但是我想要確認一下結果的值。原因是我需要一些未與SDK集成的東西來預測長期持有。

我相信從getLongPressTimeout價值爲500ms,但手勢顯然需要更長的時間 - 接近2秒。

0

查看(並因此大部分它的子類)使用getLongPressTimeout。瀏覽器中的默認超時時間可能不足。

1

通常,like Roman Nurik mentioned,您可以使用ViewConfiguration.getLongPressTimeout()以編程方式獲取長按值的值。默認值是500ms。

/** 
* Defines the default duration in milliseconds before a press turns into 
* a long press 
*/ 
private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; 

但是,長按持續時間是可定製的全球通過設置它的可訪問性。值爲短(400毫秒),中(1000毫秒)或長(1500毫秒)。你可以看到它的源代碼在Settings

// 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]); 
    } 
} 
0

這是R.array.long_press_timeout_selector_titles樣子:

<!-- Titles for the list of long press timeout options. --> 
 
    <string-array name="long_press_timeout_selector_titles"> 
 
     <!-- A title for the option for short long-press timeout [CHAR LIMIT=25] --> 
 
     <item>Short</item> 
 
     <!-- A title for the option for medium long-press timeout [CHAR LIMIT=25] --> 
 
     <item>Medium</item> 
 
     <!-- A title for the option for long long-press timeout [CHAR LIMIT=25] --> 
 
     <item>Long</item> 
 
    </string-array> 
 
    <!-- Values for the list of long press timeout options. --> 
 
    <string-array name="long_press_timeout_selector_values" translatable="false"> 
 
     <item>400</item> 
 
     <item>1000</item> 
 
     <item>1500</item> 
 
    </string-array>