基于qwertySearch和T9Search实现的通讯录
来源:互联网 发布:数据挖掘 推荐系统 编辑:程序博客网 时间:2024/06/05 20:25
基于qwertySearch 和 T9Search实现的通讯录
作者简书地址:http://www.jianshu.com/p/3c54cc71e238
官方github地址:https://github.com/handsomezhou/PinyinSearchLibrary
我的github地址: https://github.com/yin13753884368/qwertySearch
Function call in detail:
Import packages when use PinyinSearch Library(Dependent on pinyin4j-x.x.x.jar):import com.pinyinsearch.util.*;import com.pinyinsearch.model.*;The first step: Data parsing (ps:Must init baseData of PinyinSearchUnit before parse) * (PinyinUtil.parse(...))The second step: Data matching * (T9Util.match(...) or QwertyUtil.match(...))For details, please see project ContactsSearch and AppSearch.
使用要点:
//1.用Searcy初始化 PinyinSearchUnitnamePinyinSearchUnit = new PinyinSearchUnit(itemWordName);//2.初始化 初始化之前先new PinyinSearchUnitPinyinUtil.parse(namePinyinSearchUnit);//3.去匹配,输出汉字 if (headName.contains(lowerCase.substring(0, 1))) { if (QwertyUtil.match(namePinyinSearchUnit, text)) {//search by name; string = namePinyinSearchUnit.getMatchKeyword().toString(); //将要改变颜色的字体设置到bean itemCont.setColorName(string); // Log.d("call", "查 询...namePinyinSearchUnit===" + string + "....lowerCase===" + lowerCase + "..." + text); list.add(itemCont); }
使字体改变颜色
/** * 使字体变色 * @param baseText * @param highlightText if the string of highlightText is a subset of the string of baseText,highlight the string of highlightText. */ public void showTextHighlight(String baseText, String highlightText) { if (baseText != null && highlightText != null && highlightText.length() > 0) { int index = baseText.indexOf(highlightText); if (index < 0) { this.setText(baseText); return; } int len = highlightText.length(); /** * "<u><font color=#FF8C00 >"+str+"</font></u>"; //with underline * "<font color=#FF8C00 >"+str+"</font>"; //without underline * //将颜色设置成蓝色 * <color name="dark_orange">#FF8C00</color> */ Spanned spanned = Html.fromHtml(baseText.substring(0, index) + "<font color=#38ADFF >" + baseText.substring(index, index + len) + "</font>" + baseText.substring(index + len, baseText.length())); this.setText(spanned); } else { this.setText(baseText); } }
通过bean设置进去需要改变的字体颜色,在adapter中更新
0 0
- 基于qwertySearch和T9Search实现的通讯录
- 锤子桌面中运用的搜索算法 - PinyinSearch(T9Search+QwertySearch)
- 基于 链表 实现通讯录的功能
- 基于sqlite3实现的简单通讯录程序(控制台)
- 基于sqlite3实现的简单通讯录程序(控制台)
- 基于sqlite3的利用数据库实现简单通讯录
- 【C++】基于C++的封装和运算符重载的思想,实现基于通讯录类的数据查询工作
- 基于RMS的通讯录管理程序
- 基于j2me的个人通讯录
- 基于android平台的通讯录
- 基于二叉排序树写的通讯录
- 基于javase的通讯录项目
- 基于 Linux sqlite3 的通讯录
- android 通讯录的实现
- 通讯录的实现
- 手机通讯录的实现
- 通讯录的简单实现
- 通讯录的简单实现
- Alsa框架录音程序
- 嵌入式工程师入门的那些
- HihoCoder
- TCP三次握手与四次挥手
- struts2初步使用及详解
- 基于qwertySearch和T9Search实现的通讯录
- 【第一次写解题报告,,激动】POJ 1125【弗洛伊德算法-floyd算法】
- OC学习笔记之FoundationKit
- 关于Python的进程线程协程之threading模块(五)Time对象
- Day01-计算机基础
- Day02-操作系统与计算机网络
- Day03-Linux-常用命令
- Day04-Linux-用户和权限
- Day05-Linux-打包和文件系统