EditText即時搜尋,可限定時間工具類

2021-07-22 11:22:51 字數 1231 閱讀 2151

想必即時搜尋大家都做過,一般都監聽edittext字串改變或者searchview來實現。但有時候,我們不想讓它

輸入乙個字元就請求一次,刪除乙個字元也請求一次,那樣太頻繁了那有什麼好方法可以實現讓它輸入後過一秒(或

者自定義時間)再搜尋嗎?下面這個工具類可以幫到你。

public

class

realtimesearchutil

public

static

void

showsearchtip(string newtext,int time)

public

static scheduledfuture<?> schedule(runnable command, long delaytimemills)

private

static

class

searchtipthread

implements

runnable

@override

public

void

run() }}

private

static

class

myhandler

extends

handler }}

public

inte***ce

realtimesearchutillisetener

}

如何使用?

etsearch.addtextchangedlistener(textwatcher);
public textwatcher textwatcher = new textwatcher() 

@override

public

void

ontextchanged(final charsequence s, int start, int before, int count)

});}

@override

public

void

aftertextchanged(editable s)

};

歡迎star,thank yougithub:

谷歌即時搜尋團隊 即時搜尋對搜尋查詢的影響

站長們可能已經注意到您的搜尋查詢資料由於谷歌即時搜尋 goobgjsugdogle instant 的發布而發生了變化。憑藉谷歌即時搜尋,頁面可以實現動態更新,顯示包含您最新輸入的搜尋結果,這意味著人們將能夠以比往常更快的速度檢視和訪問您的 並且通常不需要點選搜尋鍵,或者敲擊 回車 鍵。儘管搜尋結果...

搜尋框即時搜尋的實現

博主最近做的專案需要實現乙個搜尋的功能 而且還需要即時搜尋 輸入關鍵字就有結果 包含關鍵字 自動顯示 這裡說一下思路 監聽edittext裡面輸入的內容 使用系統提供的filter對listview進行過濾即可 下面貼出關鍵 開啟過濾 lv search.settextfilterenabled t...

EditText支援Search按鍵搜尋

想要edittext實現軟鍵盤的搜尋按鍵搜尋可以對edittext的屬性集新增如下屬性 android imeoptions actionsearch android singleline true 設定android imeoptions actionsearch 讓軟鍵盤的回車鍵變回搜尋鍵,設定...