private class MyAdapter extends BaseAdapter {@Overridepublic int getCount() {return mAnchors.size();}@Overridepublic Object getItem(int position) {return mAnchors.get(position);}@Overridepublic long getItemId(int position) {return position;}@Overridepublic View getView(int arg0, View arg1, ViewGroup arg2) {LayoutInflater mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);View mView = mInflater.inflate(R.layout.cell_anchor, arg2, false);ImageView mImage = (ImageView) mView.findViewById(R.id.search_anchor_image);TextView mTextName = (TextView) mView.findViewById(R.id.search_anchor_name);TextView mTextId = (TextView) mView.findViewById(R.id.search_anchor_id);int chageTextColor;ForegroundColorSpan redSpan = new ForegroundColorSpan(getResources().getColor(R.color.blue));LiveRoom anchor = mAnchors.get(arg0);SpannableStringBuilder builder = new SpannableStringBuilder(anchor.anchorName);chageTextColor = anchor.anchorName.indexOf(mSearchText);if (chageTextColor != -1) {builder.setSpan(redSpan, chageTextColor, chageTextColor+ mSearchText.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);mTextName.setText(builder);} elsemTextName.setText(anchor.anchorName);SpannableStringBuilder builder1 = new SpannableStringBuilder(String.valueOf(anchor.anchorId));chageTextColor = String.valueOf(anchor.anchorId).indexOf(mSearchText);if (chageTextColor != -1) {builder1.setSpan(redSpan, chageTextColor, chageTextColor+ mSearchText.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);mTextId.setText(builder1);} elsemTextId.setText(String.valueOf(anchor.anchorId));return mView;}}


 

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 启动android后没有应用图标,找不到应用程
  2. android 系统裁剪
  3. android开源库合集
  4. LinearLayout中android:layout_gravity="
  5. android:layout_weight属性详解
  6. AMD windows7安装和打开genymotion、andr
  7. Android的动画
  8. Android(安卓)requires compiler complia
  9. Android(安卓)Studio导入项目的gradle与s
  10. Android:安装APK包以后系统文件目录的变