Flutter 搜尋內容高亮顯示

2021-10-17 14:29:09 字數 1322 閱讀 5894

flutter 搜尋內容高亮顯示方法:

///searchcontent    輸入的搜尋內容

///textcontent 需要顯示的文字內容

///frontcontent 需要另外新增在最前面的文字

///fontsize 需要顯示的字型大小

///fontcolor 需要顯示的正常字型顏色

///selectfontcolor 需要顯示的搜尋字型顏色

list

gettextspanlist

(string textcontent,

)///搜尋內容不為空並且 顯示內容中存在與搜尋內容相同的文字

if(searchcontent != null &&

searchcontent.isempty == false &&

textcontent.

contains

(searchcontent)

) _strmap =

map();

_strmap[

'content'

]= showstr;

_strmap[

'ishighlight'

]= true;

_strmaplist.

add(_strmap)

; textcontent = textcontent.

substring

( startindex + searchcontent.length, textcontent.length)

; _iscontains = textcontent.

contains

(searchcontent);if

(!_iscontains && textcontent !='')

} _strmaplist.

foreach

((map));

}else

return textspanlist;

}

呼叫方法:

richtext

( text:

textspan

( children:

gettextspanlist

('fmsekljjklgzaagfngkndgkaaffakaf'

, searchcontent:

'a')

))

Android開發 高亮顯示搜尋結果

在顯示搜尋結果的時候,我們一般會在結果中高亮顯示搜尋的關鍵字,為此好一陣搜尋資料,不過找到方法後,卻發現相當的簡單,先上效果圖 設定方法 spannablestring wordtospan new spannablestring title int start title.indexof sear...

WPF搜尋關鍵字高亮顯示

目標 在wpf中,對lucene.net進行全文檢索後的結果中包含的關鍵字進行高亮顯示。檢索結果中的關鍵字高亮顯示,在網頁中顯示是很簡單的,lucene中加標籤樣式就可以了,可是在wpf中就不行了。我在wpf中用gridcontrol顯示搜尋結果列表,gridcontrol的模板裡用textbloc...

搜尋功能,關鍵字高亮顯示

如下,直接呼叫即可 搜尋關鍵字高亮 param view param value param keys 由key.spilt 分割獲得 param context public static void setuptextview textview view,final string value,st...