AutoCompleteTextView可以根据输入的文字来显示提示, 它的Adapter可以是一个list, 也可以动态的提取数据库数据. 
写了一个例子来展示, 建立一个数据库来储存人名, 只要在AutoCompleteTextView里面输入2个字母就会显示匹配下拉单.
这是一个定制的CursorAdapter, newView会返回一个包含cursor里文字的view, bindView把cursor的数据绑定在view里, convertToString会把view的数据转换为AutoCompleteTextView显示的文字, runQueryOnBackgroundThread方法会查询数据库.

 

建立数据库, 以及添加数据, 使用CursorAdapter的数据库必须包含_id项.

 

相关文章:

  • 2021-08-28
  • 2021-04-25
  • 2021-10-04
  • 2021-07-30
  • 2021-12-11
  • 2021-10-06
  • 2021-06-27
猜你喜欢
  • 2021-09-06
  • 2021-11-28
  • 2021-11-21
  • 2021-11-07
  • 2021-12-03
  • 2021-11-20
  • 2021-11-22
相关资源
相似解决方案