@Override public View getView(int position, View view, ViewGroup arg2) { ViewHolder holder = null; if (holder == null) { holder = new ViewHolder(); if (view == null) { view = inflater.inflate(R.layout.listviewitem, null); } holder.tv = (TextView) view.findViewById(R.id.item_tv); holder.cb = (CheckBox) view.findViewById(R.id.item_cb); holder.up = (ImageView) view.findViewById(R.id.imageView_up); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } HashMap<String, Object> map = list.get(position); if (map != null) { itemString = (String) map.get(keyString[0]); upString = (String) map.get(keyString[2]); holder.tv.setText(itemString); if (upString.equals("UPLOAD")) { Log.d("upload", "字串=upload"); holder.up.setImageResource(R.drawable.upload_ok); } else { Log.d("upload", "字串不等於upload"); holder.up.setImageResource(R.drawable.upload_not); } } holder.cb.setChecked(isSelected.get(position)); return view; }
@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; }
@Override public View getView(int position, View convertView, ViewGroup parent) { TaskInfo taskInfo; if (position == 0) { TextView tv = new TextView(getApplicationContext()); tv.setTextColor(Color.WHITE); tv.setBackgroundColor(Color.GRAY); tv.setText("用户进程(" + userTaskInfos.size() + ")"); return tv; } else if (position == (userTaskInfos.size() + 1)) { TextView tv = new TextView(getApplicationContext()); tv.setTextColor(Color.WHITE); tv.setBackgroundColor(Color.GRAY); tv.setText("系统进程(" + systemTaskInfos.size() + ")"); return tv; } else if (position <= userTaskInfos.size()) { taskInfo = userTaskInfos.get(position - 1); } else { taskInfo = systemTaskInfos.get(position - 1 - userTaskInfos.size() - 1); } View view; ViewHolder holder; if (convertView != null && convertView instanceof RelativeLayout) { view = convertView; holder = (ViewHolder) view.getTag(); } else { view = View.inflate(getApplicationContext(), R.layout.list_task_item, null); holder = new ViewHolder(); holder.iv_icon = (ImageView) view.findViewById(R.id.iv_icon); holder.tv_name = (TextView) view.findViewById(R.id.tv_name); holder.tv_memsize = (TextView) view.findViewById(R.id.tv_memsize); holder.cb = (CheckBox) view.findViewById(R.id.cb); view.setTag(holder); } holder.iv_icon.setImageDrawable(taskInfo.getIcon()); holder.tv_name.setText(taskInfo.getName()); holder.tv_memsize.setText( Formatter.formatFileSize(getApplicationContext(), taskInfo.getMemsize())); holder.cb.setChecked(taskInfo.isChecked()); if (taskInfo.getPackname().equals(getPackageName())) { holder.cb.setVisibility(View.INVISIBLE); } else { holder.cb.setVisibility(View.VISIBLE); } return view; }
@Override public View getView(int paramInt, View paramView, ViewGroup paramViewGroup) { ViewHolder vh = null; if (paramView == null) { LayoutInflater infl = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); paramView = infl.inflate(R.layout.manual_list_item, null); vh = new ViewHolder(); vh.item = (TextView) paramView.findViewById(R.id.ml_item_title); vh.type = (TextView) paramView.findViewById(R.id.ml_item_type); vh.val = (TextView) paramView.findViewById(R.id.ml_item_value); vh.desc = (TextView) paramView.findViewById(R.id.ml_item_desc); vh.packagename = (TextView) paramView.findViewById(R.id.ml_item_pack); vh.cb = (CheckBox) paramView.findViewById(R.id.ml_item_cb); vh.cb.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { CheckBox cb = (CheckBox) view; ManualItemData d = (ManualItemData) cb.getTag(); d.setCek(cb.isChecked() ? 1 : 0); } }); paramView.setTag(vh); } else { vh = (ViewHolder) paramView.getTag(); } ManualItemData md = data.get(paramInt); vh.item.setText(md.getNamaField()); vh.type.setText(md.getTipe()); vh.val.setText(md.getNilai()); vh.desc.setText(md.getCatatan()); vh.packagename.setText(md.getNamaPaket()); vh.cb.setChecked(md.isCek() == 1); vh.cb.setTag(md); return paramView; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.theme_item, null); holder = new ViewHolder(); convertView.setTag(holder); holder.cb = (CheckBox) convertView.findViewById(R.id.cb_contacts); holder.tv_name = (TextView) convertView.findViewById(R.id.tv_contacts_item_name); } else { holder = (ViewHolder) convertView.getTag(); } final ZhibiaoBean weiduBean = zhibiaos.get(position); holder.tv_name.setText(weiduBean.text); holder.cb.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { setChecked(position); // weiduBean.isChecked = !weiduBean.isChecked; // notifyDataSetChanged(); } }); holder.tv_name.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { setChecked(position); // weiduBean.isChecked = !weiduBean.isChecked; // notifyDataSetChanged(); } }); holder.cb.setChecked(weiduBean.isChecked); return convertView; }
@Override public View getConvertView( CommonContactNode node, int position, View convertView, ViewGroup parent) { final int index = position; // final CommonContactNode node2 = node; ViewHolder viewHolder = null; if (convertView == null) { convertView = mInflater.inflate(R.layout.commoncontact_list_item, parent, false); viewHolder = new ViewHolder(); viewHolder.icon = (ImageView) convertView.findViewById(R.id.id_treenode_icon); viewHolder.label = (TextView) convertView.findViewById(R.id.id_treenode_label); viewHolder.cb = (CheckBox) convertView.findViewById(R.id.item_cb); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } if (node.getIcon() == -1) { viewHolder.icon.setVisibility(View.INVISIBLE); } else { viewHolder.icon.setVisibility(View.VISIBLE); viewHolder.icon.setImageResource(node.getIcon()); } viewHolder.cb.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { mAllNodes.get(index).isChecked = true; s = ""; int i = 0; for (CommonContactNode n : mAllNodes) { if (n.isChecked && n.getId() > 10000) { i++; s = s + n.getName() + " "; } } s = "(已选" + String.valueOf(i) + "人)" + s; tx.setText(s); } else { mAllNodes.get(index).isChecked = false; s = ""; int i = 0; for (CommonContactNode n : mAllNodes) { if (n.isChecked && n.getId() > 10000) { i++; s = s + n.getName() + " "; } } s = "(已选" + String.valueOf(i) + "人)" + s; tx.setText(s); } List<CommonContactNode> fuckbug = mAllNodes.get(index).getChildren(); if (fuckbug != null) for (CommonContactNode myloly : fuckbug) { myloly.isChecked = isChecked; } notifyDataSetChanged(); } }); viewHolder.label.setText(node.getName()); viewHolder.cb.setChecked(node.isChecked); if (node.isChecked) viewHolder.cb.setChecked(true); else viewHolder.cb.setChecked(false); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub final ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.contact_list_row, null); holder = new ViewHolder(); holder.cb = (CheckBox) convertView.findViewById(R.id.selectContactCB); holder.nameTv = (TextView) convertView.findViewById(R.id.textView1); holder.numberTv = (TextView) convertView.findViewById(R.id.textView2); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } final ContactInfo contact = contactListTobeFilterd.get(position); holder.nameTv.setText(contact.getName()); holder.numberTv.setText(contact.getNumber()); if (ContactPickerConstant.selectedIds.contains(contact.getContact_id())) { holder.cb.setChecked(true); } else { holder.cb.setChecked(false); } holder.cb.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (holder.cb.isChecked()) { String id = contact.getContact_id(); String name = contact.getName(); String number = contact.getNumber(); // if(!ContactPickerConstant.selectedIds.contains(id)){ ContactPickerConstant.selectedIds.add(id); ContactPickerConstant.seletectedContact.add(contact); System.out.println(id + " " + name + " " + number); // } } else { String id = contact.getContact_id(); int index = ContactPickerConstant.selectedIds.indexOf(id); ContactPickerConstant.selectedIds.remove(index); ContactPickerConstant.seletectedContact.remove(index); } } }); return convertView; }