@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_song, null); holder.mTvName = (TextView) convertView.findViewById(R.id.tv_name); holder.mTvArtist = (TextView) convertView.findViewById(R.id.tv_artist); holder.mTvDuration = (TextView) convertView.findViewById(R.id.tv_duration); holder.aboveView = convertView.findViewById(R.id.item_root); holder.behindView = convertView.findViewById(R.id.behind); convertView.setTag(holder); convertViewList.add((PullRightLayout) convertView); } else { holder = (ViewHolder) convertView.getTag(); } if (HideApplication.showListAnim) { startAnim(convertView); } SongInfo info = SongManager.with(getActivity()).getSongByIndex(position); holder.mTvName.setText(info.getTitle()); holder.mTvArtist.setText(info.getArtist() + " - " + info.getAlbum()); holder.mTvDuration.setText( CommonUtils.durationToString(info.getDuration()) + " - " + CommonUtils.getFileSize(info.getPath())); setItemSelected(holder, info.getId() == playingId); convertView.setOnClickListener(new OnItemClick(position)); holder.behindView.setOnClickListener(new OnBehindClick(position)); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; PhotoGridHolder holder = null; if (row == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new PhotoGridHolder(); holder.itemImageView = (ImageView) row.findViewById(R.id.galleryGridImage); row.setTag(holder); } else { holder = (PhotoGridHolder) row.getTag(); } String filename = getItem(position); String path = context.getFilesDir().getAbsolutePath() + "/images/" + filename; holder.itemImageView.setImageURI(Uri.parse(path)); return row; }
private ViewHolder getViewHolder(final View workingView) { final Object tag = workingView.getTag(); ViewHolder viewHolder = null; if (null == tag || !(tag instanceof ViewHolder)) { viewHolder = new ViewHolder(); viewHolder.nameView = (TextView) workingView.findViewById(R.id.name); viewHolder.dateView = (TextView) workingView.findViewById(R.id.date); viewHolder.sizeView = (TextView) workingView.findViewById(R.id.size); viewHolder.imageView = (ImageView) workingView.findViewById(R.id.image); workingView.setTag(viewHolder); } else { viewHolder = (ViewHolder) tag; } return viewHolder; }