【Android】實現(xiàn)搜索的自動補全功能
利用Sqlite模糊查詢實現(xiàn)搜索框的自動補全效果(支持字母+漢字補全)歡迎各位小伙伴提供更好的實現(xiàn)思路
源碼簡介
利用Sqlite模糊查詢實現(xiàn)搜索框的自動補全效果(支持字母+漢字補全)
歡迎各位小伙伴提供更好的實現(xiàn)思路
源碼運行截圖
源碼片段
- // 查詢相似數(shù)據(jù)--傳入一個轉(zhuǎn)換為拼音的字符串
- testArray = DatabaseAdapter.getIntance(MainActivity.this)
- .queryInfo(
- PinYin.getPinYin(editText.getText()
- .toString()));
- }
- adapter.refreshData(testArray);// Adapter刷新數(shù)據(jù)
- mListView.setVisibility(View.VISIBLE);
- }
- /**
- * 輸入之前
- */
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
- // TODO Auto-generated method stub
- }
- /**
- * 輸入之后
- */
- @Override
- public void afterTextChanged(Editable s) {
- // TODO Auto-generated method stub
- }
- });
- }
- /**
- * 獲取ArrayList數(shù)組
- *
- * @param array
- * @return
- */
- private List<string> getListArray(String[] array) {
- List<string> titleArray = new ArrayList<string>();
- for (String title : array) {
- titleArray.add(title);
- }
- return titleArray;
- }
- }</string></string></string></string></string></string>
責任編輯:chenqingxiang
來源:
網(wǎng)絡整理