@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { // inflate the GridView item layout LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.fragment_scoreboard, parent, false); // initialize the view holder viewHolder = new ViewHolder(); viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.tvTitle); viewHolder.tvDescription = (TextView) convertView.findViewById(R.id.tvDescription); convertView.setTag(viewHolder); } else { // recycle the already inflated view viewHolder = (ViewHolder) convertView.getTag(); } // update the item view ListViewItem item = getItem(position); viewHolder.tvTitle.setText(item.title); viewHolder.tvDescription.setText(item.description); return convertView; }
public View getView(final int position, View view, ViewGroup arg2) { ViewHolder viewHolder = null; final SortModel mContent = list.get(position); if (view == null) { viewHolder = new ViewHolder(); view = LayoutInflater.from(mContext).inflate(R.layout.item, null); viewHolder.tvTitle = (TextView) view.findViewById(R.id.title); viewHolder.tvLetter = (TextView) view.findViewById(R.id.catalog); viewHolder.headImg = (ImageView) view.findViewById(R.id.headImg); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } // 根据position获取分类的首字母的Char ascii值 int section = getSectionForPosition(position); // 如果当前位置等于该分类首字母的Char的位置 ,则认为是第一次出现 if (position == getPositionForSection(section)) { viewHolder.tvLetter.setVisibility(View.VISIBLE); viewHolder.tvLetter.setText(mContent.getSortLetters()); } else { viewHolder.tvLetter.setVisibility(View.GONE); } viewHolder.tvTitle.setText(this.list.get(position).getName()); imageLoader.DisplayImage(this.list.get(position).getAvater(), viewHolder.headImg); return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = View.inflate(mActivity, R.layout.list_item_news, null); holder = new ViewHolder(); holder.ivIcon = (ImageView) convertView.findViewById(R.id.iv_icon); holder.tvTitle = (TextView) convertView.findViewById(R.id.tv_title); holder.tvDate = (TextView) convertView.findViewById(R.id.tv_date); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } News news = getItem(position); holder.tvTitle.setText(news.title); holder.tvDate.setText(news.pubdate); mBitmapUtils.display(holder.ivIcon, news.listimage); String ids = SharePreferenceUtils.getString(mActivity, PREF_NEWS_READ, ""); // 如果再已读列表中 if (ids.contains(getItem(position).id)) { holder.tvTitle.setTextColor(Color.GRAY); } else { holder.tvTitle.setTextColor(Color.BLACK); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; View view = convertView; if (view == null) { view = LayoutInflater.from(mContext).inflate(R.layout.adapter_nodelist, parent, false); viewHolder = new ViewHolder(); viewHolder.tvDate = (TextView) view.findViewById(R.id.note_date_text); viewHolder.tvTitle = (TextView) view.findViewById(R.id.note_title_text); viewHolder.tvContent = (TextView) view.findViewById(R.id.note_content_text); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } Note note = noteList.get(position); viewHolder.tvTitle.setText(note.getTitle()); viewHolder.tvContent.setText(note.getContent()); viewHolder.tvDate.setText(note.getDateUpdated()); return view; }
public View getView(final int position, View view, ViewGroup arg2) { ViewHolder viewHolder = null; final SortModel mContent = list.get(position); if (view == null) { viewHolder = new ViewHolder(); view = LayoutInflater.from(mContext).inflate(R.layout.item, null); viewHolder.tvTitle = (TextView) view.findViewById(R.id.title); viewHolder.tvLetter = (TextView) view.findViewById(R.id.catalog); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } // ����position��ȡ���������ĸ��Char asciiֵ int section = getSectionForPosition(position); // �����ǰλ�õ��ڸ÷�������ĸ��Char��λ�� ������Ϊ�ǵ�һ�γ��� if (position == getPositionForSection(section)) { viewHolder.tvLetter.setVisibility(View.VISIBLE); viewHolder.tvLetter.setText(mContent.getSortLetters()); } else { viewHolder.tvLetter.setVisibility(View.GONE); } viewHolder.tvTitle.setText(this.list.get(position).getName()); return view; }
@Override public View getView(final int position, View view, ViewGroup arg2) { ViewHolder viewHolder = null; final ContactSortModel item = (ContactSortModel) getItem(position); if (view == null) { viewHolder = new ViewHolder(); view = LayoutInflater.from(mContext).inflate(R.layout.contact_item, null); viewHolder.tvTitle = (TextView) view.findViewById(R.id.title); viewHolder.tvLetter = (TextView) view.findViewById(R.id.catalog); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } // 根据position获取分类的首字母的Char ascii值 int section = getSectionForPosition(position); // 如果当前位置等于该分类首字母的Char的位置 ,则认为是第一次出现 if ("添加好友".equals(item.getRoster().getAlias()) || "新朋友".equals(item.getRoster().getAlias())) { viewHolder.tvLetter.setVisibility(View.GONE); } else if (position == getPositionForSection(section)) { viewHolder.tvLetter.setVisibility(View.VISIBLE); viewHolder.tvLetter.setText(item.getSortLetters()); } else { viewHolder.tvLetter.setVisibility(View.GONE); } viewHolder.tvTitle.setText(item.getRoster().getAlias()); ImageView image = (ImageView) view.findViewById(R.id.iv_icon); // 获得ImageView对象 viewHolder.tvImage = image; if ("添加好友".equals(item.getRoster().getAlias())) { viewHolder.tvImage.setBackgroundResource(R.drawable.contact_add_friends); } else if ("新朋友".equals(item.getRoster().getAlias())) { viewHolder.tvImage.setBackgroundResource(R.drawable.contact_new_friends); } else { viewHolder.tvImage.setBackgroundResource(R.drawable.default_mobile_avatar); File file = new File("mnt/sdcard/Wanglai/Avatar/" + item.getRoster().getJid() + ".png"); if (file.exists()) { Bitmap bitmap = getLoacalBitmap( "mnt/sdcard/Wanglai/Avatar/" + item.getRoster().getJid() + ".png"); // 从本地取图片vcard // 设置Bitmap image.setImageBitmap(bitmap); // 设置Imageview image.setAdjustViewBounds(true); image.setMaxHeight(60); image.setMaxWidth(60); viewHolder.tvImage = image; viewHolder.tvImage.setBackgroundResource(0); } } return view; }
public View getView(final int position, View view, ViewGroup arg2) { ViewHolder viewHolder = null; if (view == null) { viewHolder = new ViewHolder(); view = LayoutInflater.from(mContext).inflate(R.layout.association_fragment_one_item, null); viewHolder.tvIcon = (ImageView) view.findViewById(R.id.association_fragment_one_icon); viewHolder.tvTitle = (TextView) view.findViewById(R.id.association_fragment_one_title); viewHolder.tvLetter = (TextView) view.findViewById(R.id.association_fragment_one_catalog); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } final Association mDemo = list.get(position); if (position == 0) { // 设置社团首字母 viewHolder.tvLetter.setVisibility(View.VISIBLE); viewHolder.tvLetter.setText(mDemo.getKey()); } else { String lastCatalog = list.get(position - 1).getKey(); if (mDemo.getKey().equals(lastCatalog)) { viewHolder.tvLetter.setVisibility(View.GONE); } else { viewHolder.tvLetter.setVisibility(View.VISIBLE); viewHolder.tvLetter.setText(mDemo.getKey()); } } // 设置社团标题 viewHolder.tvTitle.setText(this.list.get(position).getName()); String pic = this.list.get(position).getIcon(); // 设置LOGO - 文件名 - 资源ID // 方式1:反射 // 通过反射机制,把icon文件名,转化成资源id,设置到对应的社团imageView中 // // try { // field = draw.getDeclaredField(pic); // resId = field.getInt(pic); // } catch (Exception e) { // e.printStackTrace(); // resId = R.drawable.association_logo_0; // } // 方式2:getIdentifier int resId = mContext.getResources().getIdentifier(pic, "drawable", "pyp.navigation.main"); // 找不到资源就设置为默认logo if (resId == 0) resId = R.drawable.association_logo_0; // 设置为社团Logo图像资源 viewHolder.tvIcon.setImageResource(resId); return view; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final PackageItem item = getItem(position); ViewHolder holder; if (convertView == null) { LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = li.inflate(R.layout.package_row, parent, false); holder = new ViewHolder(); holder.tvTitle = (TextView) convertView.findViewById(R.id.example_row_tv_title); holder.tvDescription = (TextView) convertView.findViewById(R.id.example_row_tv_description); holder.bAction1 = (ImageButton) convertView.findViewById(R.id.button_edit_rule); holder.bAction2 = (Button) convertView.findViewById(R.id.button_disable_rule); holder.bAction3 = (ImageButton) convertView.findViewById(R.id.button_delete_rule); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } ((SwipeListView) parent).recycle(convertView, position); holder.tvTitle.setText(item.getName()); holder.tvDescription.setText(item.toString()); holder.bAction1.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mHandler.obtainMessage(RuleList.MESSAGE_EDIT_RULE, position, -1).sendToTarget(); } }); holder.bAction2.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mHandler.obtainMessage(RuleList.MESSAGE_DISABLE_RULE, position, -1).sendToTarget(); } }); holder.bAction3.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mHandler.obtainMessage(RuleList.MESSAGE_DELETE_RULE, position, -1).sendToTarget(); } }); return convertView; }
@Override protected View createView(LayoutInflater inflater, ViewGroup parent) { View v = inflater.inflate(R.layout.row_simple_3, null); ViewHolder viewHolder = new ViewHolder(); Typeface boldCondensed = Gh4Application.get(mContext).boldCondensed; viewHolder.tvTitle = (TextView) v.findViewById(R.id.tv_title); viewHolder.tvTitle.setTypeface(boldCondensed); viewHolder.tvDesc = (TextView) v.findViewById(R.id.tv_desc); viewHolder.tvExtra = (TextView) v.findViewById(R.id.tv_extra); viewHolder.tvExtra.setTextAppearance(mContext, R.style.default_text_micro); v.setTag(viewHolder); return v; }
public View getView(final int position, View convertView, ViewGroup parent) { CategoryName = categoryList.get(position); LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = mInflater.inflate(R.layout.adapter_view_result, null); holder = new ViewHolder(); holder.tvTitle = (TextView) convertView.findViewById(R.id.tvtitle); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); holder.tvTitle.setText(CategoryName); // holder.rlMain.setBackgroundColor(context.getResources().getColor(R.color.text_link)); return convertView; }
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View convertView = mLayoutInflater.inflate(mLayout, null); ViewHolder holder = new ViewHolder(); convertView.findViewById(R.id.iv_right_arrow).setVisibility(View.GONE); holder.tvTitle = (TextView) convertView.findViewById(R.id.tv_category_list_title); holder.ivIcon = (ImageView) convertView.findViewById(R.id.iv_category_icon); holder.cbFilter = (CheckBox) convertView.findViewById(R.id.cb_select_category); holder.cbFilter.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { checkAction(buttonView, isChecked); } }); convertView.setTag(holder); if (categoryColIndex == -1) categoryColIndex = cursor.getColumnIndex(NodeDetailsData.CATEGORY_COL); convertView.setOnClickListener(onItemClickListener); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { holder = null; if (null == convertView) { holder = new ViewHolder(); if (null == mInflater) { mInflater = LayoutInflater.from(MainActivity.instance); } convertView = mInflater.inflate(R.layout.unit_supplies, null, false); holder.tvTitle = (TextView) convertView.findViewById(R.id.supplies_unit_title); holder.tvValue = (TextView) convertView.findViewById(R.id.supplies_unit_value); holder.tvGrowth = (TextView) convertView.findViewById(R.id.supplies_unit_growth); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } Pair pair = (Pair) getItem(position); holder.tvTitle.setText(pair.getTitle()); holder.tvValue.setText(Strs.f(pair.getValue())); holder.tvGrowth.setText(Strs.f(pair.getGrowth())); return convertView; }
@Override public View getItemView(SingleWorkout workout, View convertView, ViewGroup parent) { super.getItemView(workout, convertView, parent); final ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item_cards, parent, false); holder = new ViewHolder(); holder.ivImage = (ImageView) convertView.findViewById(R.id.imageViewProfilePic); holder.ivPeek1 = (ImageView) convertView.findViewById(R.id.imageViewPeek1); holder.ivPeek2 = (ImageView) convertView.findViewById(R.id.imageViewPeek2); holder.ivPeek3 = (ImageView) convertView.findViewById(R.id.imageViewPeek3); holder.tvTitle = (TextView) convertView.findViewById(R.id.textViewTitle); holder.tvDifficulty = (TextView) convertView.findViewById(R.id.textViewDifficulty); holder.tvTime = (TextView) convertView.findViewById(R.id.textViewTime); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.tvTitle.setText(workout.get_title()); holder.tvTime.setText(workout.get_time()); holder.tvDifficulty.setText(workout.get_difficulty()); try { JSONArray mJsonArray = new JSONArray(workout.get_pictureArrayJSON()); String pictureVal1 = "w" + mJsonArray.getString(0); String pictureVal2 = "w" + mJsonArray.getString(1); String pictureVal3 = "w" + mJsonArray.getString(2); holder.ivPeek1.setImageResource( getContext() .getResources() .getIdentifier(pictureVal1, "drawable", getContext().getPackageName())); holder.ivPeek2.setImageResource( getContext() .getResources() .getIdentifier(pictureVal2, "drawable", getContext().getPackageName())); holder.ivPeek3.setImageResource( getContext() .getResources() .getIdentifier(pictureVal3, "drawable", getContext().getPackageName())); } catch (JSONException e) { e.printStackTrace(); } // needed to get User profile pic for parse feed try { ParseUser mUser = workout.getParseUser("user"); mUser.fetchInBackground( new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { try { final byte[] mBytes = parseObject.getBytes("photo"); if (mBytes != null) { new Handler() .post( new Runnable() { @Override public void run() { Bitmap bitmap = BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length); holder.ivImage.setImageBitmap(bitmap); } }); } } catch (Exception f) { Log.e(TAG, f.getMessage()); } } }); } catch (Exception e) { Log.e(TAG, e.getMessage()); } // still need to populate the ivPeek with icons return convertView; }