比较我的联系人列表中的电话号码和一组数字

时间:2014-09-12 11:54:48

标签: android string listview getview

您需要帮助,同时尝试比较两个字符串,但我的"如果"永远不会返回true我希望将图像设置为可见或不可见,如果我的数字存在于我的数组中,这里是我的代码:

 public View getView(final int position, View convertView, ViewGroup parent) {

    View view = convertView;
    if (view == null){
        LayoutInflater inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.alluser_row, null);

        holder = new ViewHolder();
        view.setTag(holder);
        holder.tvname = (TextView) view.findViewById(R.id.tvname);
        holder.tvPhoneNo = (TextView) view.findViewById(R.id.tvphone);
        holder.img = (ImageView)view.findViewById(R.id.img);

    } else {
        holder = (ViewHolder) view.getTag();
    }

    if ((items == null)||((position + 1) > items.size()))
        return view;

    objBean = items.get(position);


    if (holder.tvname != null && null != objBean.getName()
            && objBean.getName().trim().length() > 0) {
        holder.tvname.setText(Html.fromHtml(objBean.getName()));
    }
    if (holder.tvPhoneNo != null && null != objBean.getPhoneNo()
            && objBean.getPhoneNo().trim().length() > 0) {
        holder.tvPhoneNo.setText(Html.fromHtml(objBean.getPhoneNo()));
    }   

    for (int i = 0; i <Emc2Contacts.length; i++) {

             if (objBean.getPhoneNo().toString().equals(Emc2Contacts[i].toString())){

                 holder.img.setVisibility(View.VISIBLE);
             } else {                 
                 holder.img.setVisibility(View.GONE); 
             }
    }

当我将我的联系电话号码与这样的简单字符串进行比较时

if(objBean.getPhoneNo().toString().equals("+2213334534")){
   holder.img.setVisibility(View.VISIBLE);
}

我有我所期待的。任何帮助都会很愉快

0 个答案:

没有答案