@Override public View getChildView( int groupPosition, final int childPosition, boolean isLastChild, View rowView, ViewGroup parent) { if (rowView == null) { LayoutInflater inflater = context.getLayoutInflater(); rowView = inflater.inflate(R.layout.adapter_listview_about, null); // configure view holder ViewHolder viewHolder = new ViewHolder(); viewHolder.image = (ImageView) rowView.findViewById(R.id.img); viewHolder.text = (TextView) rowView.findViewById(R.id.txt); viewHolder.text2 = (TextView) rowView.findViewById(R.id.description); rowView.setTag(viewHolder); } DeveloperBean developer = childData.get(headers.get(groupPosition)).get(childPosition); ViewHolder holder = (ViewHolder) rowView.getTag(); holder.image.setImageDrawable(developer.getImage()); holder.text.setText(developer.getTitle()); holder.text2.setText(developer.getDescription()); return rowView; }
/** Overrides newView() to inflate the list item views. */ @Override public View newView(Context context, Cursor cursor, ViewGroup viewGroup) { // Inflates the list item layout. final View itemLayout = mInflater.inflate(R.layout.contact_list_item, viewGroup, false); // Creates a new ViewHolder in which to store handles to each view // resource. This // allows bindView() to retrieve stored references instead of // calling findViewById for // each instance of the layout. final ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) itemLayout.findViewById(android.R.id.text1); holder.text2 = (TextView) itemLayout.findViewById(android.R.id.text2); holder.icon = (QuickContactBadge) itemLayout.findViewById(android.R.id.icon); holder.selectContact = (CheckBox) itemLayout.findViewById(android.R.id.checkbox); holder.selectContact.setFocusable(false); holder.selectContact.setClickable(false); holder.selectContact.setTag(tagForCheckBox); tagForCheckBox++; // Stores the resourceHolder instance in itemLayout. This makes // resourceHolder // available to bindView and other methods that receive a handle to // the item view. itemLayout.setTag(holder); // Returns the item layout view return itemLayout; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // Log.d(LOGTAG, infos.get(position)); // TODO Auto-generated method stub ViewHolder viewHolder; if (convertView == null) { convertView = mLayoutInflater.inflate(R.layout.program_list_item, null); viewHolder = new ViewHolder(); viewHolder.text1 = (TextView) convertView.findViewById(R.id.time); viewHolder.text2 = (TextView) convertView.findViewById(R.id.program); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.text1.setText(infos.get(position).getTime()); viewHolder.text2.setText(infos.get(position).getProgram()); if (infos.get(position).getCurProgram()) { viewHolder.text1.setTextColor(mContext.getResources().getColor(R.color.green)); viewHolder.text2.setTextColor(mContext.getResources().getColor(R.color.green)); } else { viewHolder.text1.setTextColor(mContext.getResources().getColor(R.color.kkblack)); viewHolder.text2.setTextColor(mContext.getResources().getColor(R.color.kkblack)); } return convertView; }
/** *** Depends upon data size called for each row , Create each ListView row **** */ public View getView(final int position, final View convertView, ViewGroup parent) { View vi = convertView; ViewHolder holder; if (convertView == null) { /** **** Inflate tabitem.xml file for each row ( Defined below ) ****** */ vi = inflater.inflate(R.layout.desired_courses_listview, null); /** **** View Holder Object to contain tabitem.xml file elements ***** */ holder = new ViewHolder(); holder.text1 = (TextView) vi.findViewById(R.id.desiredCourseDepartment); holder.text2 = (TextView) vi.findViewById(R.id.desiredCourseNumber); holder.text3 = (TextView) vi.findViewById(R.id.desiredCourseTitle); holder.button1 = (Button) vi.findViewById(R.id.desiredCourseButton); /** ********** Set holder with LayoutInflater *********** */ vi.setTag(holder); } else holder = (ViewHolder) vi.getTag(); if (arrayList.size() <= 0) { // holder.text.setText("No Data"); } else { /** *** Get each Model object from Arraylist ******* */ tempValues = null; tempValues = (DesiredCourseModel) arrayList.get(position); /** ********** Set Model values in Holder elements ********** */ holder.text1.setText(tempValues.getDepartment()); holder.text2.setText(tempValues.getCourse_number()); holder.text3.setText(tempValues.getCourse_title()); /** ****** Set Item Click Listner for LayoutInflater for each row ****** */ holder.button1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { try { arrayList.remove(getItem(position)); notifyDataSetChanged(); // notifyDataSetInvalidated(); if (arrayList.size() <= 0) { convertView.setVisibility(View.GONE); } else { convertView.setVisibility(View.VISIBLE); } } catch (Exception e) { e.printStackTrace(); } } }); } return vi; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder vh = null; if (convertView == null) { vh = new ViewHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.patientcase_item, null); vh.text1 = (TextView) convertView.findViewById(R.id.txt1); vh.text2 = (TextView) convertView.findViewById(R.id.txt2); vh.img = (ImageView) convertView.findViewById(R.id.imgCheck); vh.img.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { BingLiDangAnInfo info = list.get(Integer.valueOf(v.getTag() + "")); if (info.isChecked()) { info.setChecked(false); } else { info.setChecked(true); } callback.gotoDel(position); notifyDataSetChanged(); } }); convertView.setTag(vh); } else { vh = (ViewHolder) convertView.getTag(); } BingLiDangAnInfo info = list.get(position); vh.img.setTag(position); vh.text1.setText("主治医生:" + info.getDoctorName()); vh.text2.setText("创建日期:" + info.getTime()); if (info.isChecked()) { vh.img.setImageResource(R.drawable.per_gou_yes); } else { vh.img.setImageResource(0); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(android.R.layout.two_line_list_item, null); convertView.setTag(holder); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); } else { holder = (ViewHolder) convertView.getTag(); } Event event = getItem(position); holder.text1.setText(event.title); holder.text2.setText(event.text); return convertView; }
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.row, null); holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } if ((position >= 0) && (position < essen.length)) { holder.text1.setText(essen[position].getName()); holder.text2.setText(essen[position].getPreisToString()); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { switch (getItemViewType(position)) { case ITEM_TYPE_VIEW: { convertView = (ItemListItem) inflater.inflate(R.layout.item_listitem_view, parent, false); ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom); holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top); convertView.setTag(holder); break; } case ITEM_TYPE_EDIT: { convertView = (ItemListItem) inflater.inflate(R.layout.item_listitem_equippeditem, parent, false); ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom); holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top); convertView.setTag(holder); break; } case ITEM_TYPE_SEEK: { convertView = (ViewGroup) inflater.inflate(R.layout.item_listitem_seek, parent, false); SeekViewHolder viewHolder = new SeekViewHolder(); viewHolder.seek = (SeekBarEx) convertView.findViewById(R.id.wheel); viewHolder.text = (TextView) convertView.findViewById(R.id.wheel_label); viewHolder.value = (Button) convertView.findViewById(R.id.wheel_value); convertView.setTag(viewHolder); break; } case ITEM_TYPE_COMBAT_TALENT: case ITEM_TYPE_SIMPLE_TALENT: { convertView = inflater.inflate(R.layout.item_listitem_talent, parent, false); TalentViewHolder holder = new TalentViewHolder(); // name holder.text1 = (TextView) convertView.findViewById(R.id.talent_list_item_text1); // be holder.text2 = (TextView) convertView.findViewById(R.id.talent_list_item_text2); // probe holder.text3 = (TextView) convertView.findViewById(R.id.talent_list_item_text3); // value / at holder.text4 = (TextView) convertView.findViewById(R.id.talent_list_item_text4); // pa holder.text5 = (TextView) convertView.findViewById(R.id.talent_list_item_text5); holder.indicator = (ImageView) convertView.findViewById(R.id.talent_list_item_indicator); convertView.setTag(holder); break; } case ITEM_TYPE_MODIFIER: { // We need the layoutinflater to pick up the view from xml // Pick up the TwoLineListItem defined in the xml file convertView = inflater.inflate(R.layout.item_listitem_modifier, parent, false); ModifierViewHolder holder = new ModifierViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.active = (CheckBox) convertView.findViewById(R.id.active); convertView.setTag(holder); break; } case ITEM_TYPE_HEADER: { convertView = inflater.inflate(R.layout.item_listitem_header, parent, false); HeaderViewHolder holder = new HeaderViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); convertView.setTag(holder); break; } case ITEM_TYPE_NOTES: { convertView = inflater.inflate(R.layout.item_listitem_event, parent, false); EventViewHolder holder = new EventViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); convertView.setTag(holder); break; } case ITEM_TYPE_PURSE: convertView = inflater.inflate(R.layout.item_listitem_purse, parent, false); PurseViewHolder holder = new PurseViewHolder(); holder.currencySpinner = (Spinner) convertView.findViewById(R.id.sp_currency); holder.header = (TextView) convertView.findViewById(R.id.tv_currency_header); holder.picker = new NumberPicker[4]; holder.picker[0] = (NumberPicker) convertView.findViewById(R.id.popup_purse_dukat); holder.picker[1] = (NumberPicker) convertView.findViewById(R.id.popup_purse_silver); holder.picker[2] = (NumberPicker) convertView.findViewById(R.id.popup_purse_heller); holder.picker[3] = (NumberPicker) convertView.findViewById(R.id.popup_purse_kreuzer); holder.labels = new TextView[4]; holder.labels[0] = (TextView) convertView.findViewById(R.id.tv_currency1); holder.labels[1] = (TextView) convertView.findViewById(R.id.tv_currency2); holder.labels[2] = (TextView) convertView.findViewById(R.id.tv_currency3); holder.labels[3] = (TextView) convertView.findViewById(R.id.tv_currency4); convertView.setTag(holder); break; } } FlippableViewHolder.prepare(position, convertView, (ListView) parent); Listable item = getItem(position); if (item instanceof EquippedItem) { convertView = prepareView((EquippedItem) item, position, convertView, parent); } else if (item instanceof Attribute) { convertView = prepareView((Attribute) item, position, convertView, parent); } else if (item instanceof Talent) { convertView = prepareView((Talent) item, position, convertView, parent); } else if (item instanceof Spell) { convertView = prepareView((Spell) item, position, convertView, parent); } else if (item instanceof Art) { convertView = prepareView((Art) item, position, convertView, parent); } else if (item instanceof Modificator) { convertView = prepareView((Modificator) item, position, convertView, parent); } else if (item instanceof HeaderListItem) { convertView = prepareView((HeaderListItem) item, position, convertView, parent); } else if (item instanceof FileListable) { convertView = prepareView((FileListable) item, position, convertView, parent); } else if (item instanceof NotesItem) { convertView = prepareView((NotesItem) item, position, convertView, parent); } else if (item instanceof PurseListable) { convertView = prepareView((PurseListable) item, position, convertView, parent); } if (item instanceof Markable) { Util.applyRowStyle((Markable) item, convertView, position); } else { Util.applyRowStyle(convertView, position); } return convertView; }