コード例 #1
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.list_item, null);
        holder = new ViewHolder();
        holder.alpha = (TextView) convertView.findViewById(R.id.alpha);
        holder.name = (TextView) convertView.findViewById(R.id.name);
        holder.number = (TextView) convertView.findViewById(R.id.number);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }
      ContentValues cv = list.get(position);
      String name = cv.getAsString(NAME);
      String number = cv.getAsString(NUMBER);
      holder.name.setText(name);
      holder.number.setText(number);

      // 当前联系人的sortKey
      String currentStr = getAlpha(list.get(position).getAsString(SORT_KEY));
      // 上一个联系人的sortKey
      String previewStr =
          (position - 1) >= 0 ? getAlpha(list.get(position - 1).getAsString(SORT_KEY)) : " ";
      /** 判断显示#、A-Z的TextView隐藏与可见 */
      if (!previewStr.equals(currentStr)) { // 当前联系人的sortKey!=上一个联系人的sortKey,说明当前联系人是新组。
        holder.alpha.setVisibility(View.VISIBLE);
        holder.alpha.setText(currentStr);
      } else {
        holder.alpha.setVisibility(View.GONE);
      }
      return convertView;
    }
コード例 #2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = convertView;
      final ViewHolder holder;
      if (convertView == null) {
        view = LayoutInflater.from(mContext).inflate(R.layout.xianshi_shouji_leavewords_item, null);
        holder = new ViewHolder();
        holder.content = (TextView) view.findViewById(R.id.pinglun_content);
        holder.date = (TextView) view.findViewById(R.id.pinglun_date);
        holder.name = (TextView) view.findViewById(R.id.pinglun_name);
        holder.category = (TextView) view.findViewById(R.id.pinglun_category);
        holder.number = (TextView) view.findViewById(R.id.pinglun_nub);
        view.setTag(holder);
      } else {
        holder = (ViewHolder) view.getTag();
      }
      holder.content.setText(mLinkedList.get(position).getContent());
      holder.date.setText(
          MyUtlis.TimeStamp2DateList(mLinkedList.get(position).getCtime(), context));
      holder.name.setText(
          getResources().getString(R.string.contact_name)
              + mLinkedList.get(position).getNickname());
      holder.category.setText(mLinkedList.get(position).getCategory());
      holder.number.setText(
          getResources().getString(R.string.contact) + mLinkedList.get(position).getContact());

      return view;
    }
コード例 #3
0
ファイル: GreenActivity.java プロジェクト: hzjiyun/Android
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      final ViewHolder holder;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.phonelistview, null); // phone
        holder = new ViewHolder();
        holder.name = (TextView) convertView.findViewById(R.id.namephone);
        holder.number = (TextView) convertView.findViewById(R.id.numberphone);
        holder.cb = (CheckBox) convertView.findViewById(R.id.widget_checkbox1);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolder) convertView.getTag();
      }

      ContentValues cv = list.get(position);
      holder.name.setText(cv.getAsString(NAME));
      holder.number.setText(cv.getAsString(NUMBER));
      Log.i("kkkkkkkkkkk", "--------------------getViewsortkey: " + cv.getAsString(SORT_KEY));

      Boolean b = isSelectedphone.get(position);
      if (null == b) b = false;
      if (convertView instanceof ViewGroup) {
        ViewGroup g = (ViewGroup) convertView;
        for (int i = 0; i < g.getChildCount(); i++) {
          View v = g.getChildAt(i);
          if (v instanceof CheckBox) {
            ((CheckBox) v).setChecked(b);
            break;
          }
        }
      }

      return convertView;
    }
コード例 #4
0
 @Override
 public View getView(int i, View view, ViewGroup viewGroup) {
   ViewHolder viewHolder = null;
   if (view == null) {
     view = LayoutInflater.from(context).inflate(R.layout.contacts_item, null);
     viewHolder = new ViewHolder();
     viewHolder.name = (TextView) view.findViewById(R.id.name);
     viewHolder.number = (TextView) view.findViewById(R.id.number);
     viewHolder.check = (CheckBox) view.findViewById(R.id.check);
     view.setTag(viewHolder);
   } else viewHolder = (ViewHolder) view.getTag();
   viewHolder.name.setText(list.get(i).getName());
   viewHolder.number.setText(list.get(i).getPhonenumber());
   viewHolder.check.setOnCheckedChangeListener(
       new CompoundButton.OnCheckedChangeListener() {
         @Override
         public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
           if (isChecked) {
             mCBFlag.put(i, true);
           } else {
             mCBFlag.put(i, false);
           }
         }
       });
   /*CheckBox监听事件必须放在setChecked之前,否则后果自负*/
   viewHolder.check.setChecked(mCBFlag.get(i));
   Log.d("position:", "i=" + i + ",view=" + view);
   return view;
 }
コード例 #5
0
ファイル: T9Adapter.java プロジェクト: jadore/JadoreContact
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder = null;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.home_t9_list_item, parent, false);
      holder = new ViewHolder();
      holder.name = (TextView) convertView.findViewById(R.id.name);
      holder.pinyin = (TextView) convertView.findViewById(R.id.pinyin);
      holder.number = (TextView) convertView.findViewById(R.id.number);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.name.setText(list.get(position).getDisplayName());
    String formattedNumber = list.get(position).getPinyin();

    if (null == filterNum || "".equals(filterNum)) {
      //			holder.pinyin.setVisibility(View.INVISIBLE);
      holder.number.setText(list.get(position).getPhoneNum());
    } else {
      //			holder.pinyin.setVisibility(View.VISIBLE);
      holder.number.setText(
          Html.fromHtml(
              list.get(position)
                  .getPhoneNum()
                  .replace(filterNum, "<font color='#cc0000'>" + filterNum + "</font>")));
      if (!TextUtils.isEmpty(filterNum)) {
        for (int i = 0; i < filterNum.length(); i++) {
          char c = filterNum.charAt(i);
          if (TextUtils.isDigitsOnly(String.valueOf(c))) {
            char[] zms = digit2Char(Integer.parseInt(c + ""));
            if (zms != null) {
              for (char c1 : zms) {
                formattedNumber =
                    formattedNumber.replaceAll(
                        String.valueOf(c1).toUpperCase(),
                        "%%" + String.valueOf(c1).toUpperCase() + "@@");
              }
              formattedNumber = formattedNumber.replaceAll("%%", "<font color='#cc0000'>");
              formattedNumber = formattedNumber.replaceAll("@@", "</font>");
            }
          }
        }
        // holder.pinyin.setText(Html.fromHtml(formattedNumber));
      }
    }

    convertView.setTag(holder);
    return convertView;
  }
  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
    final View v = li.inflate(R.layout.push_contact_selection_list_item, parent, false);
    final ViewHolder holder = new ViewHolder();

    if (v != null) {
      holder.name = (TextView) v.findViewById(R.id.name);
      holder.number = (TextView) v.findViewById(R.id.number);
      holder.checkBox = (CheckBox) v.findViewById(R.id.check_box);
      holder.contactPhoto = (ImageView) v.findViewById(R.id.contact_photo_image);

      if (!multiSelect) holder.checkBox.setVisibility(View.GONE);

      v.setTag(R.id.holder_tag, holder);
      v.setTag(R.id.contact_info_tag, new DataHolder());
    }
    return v;
  }
コード例 #7
0
ファイル: NewSmsAdapter.java プロジェクト: wwhui/BYOD
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder = null;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.newsms_list_item, parent, false);
      holder = new ViewHolder();
      holder.name = (TextView) convertView.findViewById(R.id.name);
      holder.number = (TextView) convertView.findViewById(R.id.number);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.name.setText(list.get(position).getDisplayName());
    holder.number.setText(list.get(position).getPhoneNum());

    convertView.setTag(holder);
    return convertView;
  }