【Android】Implement the auto-complete function for search

【Android】Implement the auto-complete function for search

Source code introduction

Using Sqlite fuzzy query to achieve automatic completion of search box (support letter + Chinese character completion)

Welcome all friends to provide better implementation ideas

Source code running screenshot

Source code snippet

  1. // Query similar data--pass in a string converted to pinyin  
  2. testArray = DatabaseAdapter.getIntance(MainActivity. this )
  3. .queryInfo(
  4. PinYin.getPinYin(editText.getText()
  5. .toString()));
  6. }
  7.   
  8. adapter.refreshData(testArray); // Adapter refreshes data  
  9. mListView.setVisibility(View.VISIBLE);
  10. }
  11.   
  12. /**
  13. * Before input
  14. */  
  15. @Override  
  16. public   void beforeTextChanged(CharSequence s, int start, int count,
  17. int after) {
  18. // TODO Auto-generated method stub  
  19.   
  20. }
  21.   
  22. /**
  23. * After input
  24. */  
  25. @Override  
  26. public   void afterTextChanged(Editable s) {
  27. // TODO Auto-generated method stub  
  28.   
  29. }
  30. });
  31. }
  32.   
  33. /**
  34. * Get the ArrayList array
  35. *
  36. * @param array
  37. * @return
  38. */  
  39. private List<string> getListArray(String[] array) {
  40. List<string> titleArray = new ArrayList<string>();
  41. for (String title : array) {
  42. titleArray.add(title);
  43. }
  44. return titleArray;
  45. }
  46.   
  47. }</string></string></string></string></string></string>

Source code link: http://download..com/data/1968754

<<:  Realize various gesture operations for visualization

>>:  From 0 to 100——The History of Zhihu’s Architecture Changes

Recommend

Good news for people with allergies. Will the new coronavirus avoid you?

[This issue's rumor]: Recently, there are rum...

In-depth analysis | How to effectively control promotion costs and improve ROI

Search engine marketing has been carried out in m...

The cold wave is coming! Have the long johns you bought arrived?

This article was first published by Hunzhi (WeCha...

The “universal” methodology for bidding advertising!

The editor has personally operated and placed adv...

How to build private domain traffic on WeChat for enterprises?

When it comes to live streaming sales, Lao Luo’s ...

Practice: How to implement member repurchase in the 618 event?

This article mainly analyzes how to conduct membe...

Event Operation: Is your event ineffective?

Organizing activities is the daily work of our op...

Is the popular sleep aid “white noise” fake science or real scam?

"My eyes were as big as bells, and I tossed ...

Paying someone to rate your looks? Don't take it too seriously

Recently, "rating appearance" has becom...

Traffic generation solutions such as Zhihu, Tik Tok, and Video Account!

A practical private domain operation plan must be...

A15 wins first place, but cannot cover up Apple iPhone's problems

The iPhone 13 arrived as expected, but the new fe...

Oculus Rift will be available in the first quarter of this year

As a benchmark in the field of virtual reality, e...