@SuppressWarnings("deprecation") @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { convertView = LayoutInflater.from(mInstance).inflate(R.layout.listview_item, null); holder = new ViewHolder(); holder.checkBox = (CheckBox) convertView.findViewById(R.id.check_box); holder.textView = (TextView) convertView.findViewById(R.id.app_name); holder.imageView = (ImageView) convertView.findViewById(R.id.app_logo); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } final PackageInfo packageInfo = mInstalledList.get(position); holder.textView.setText( packageInfo.applicationInfo.loadLabel(mInstance.getPackageManager()).toString()); holder.imageView.setImageResource(packageInfo.applicationInfo.icon); Drawable drawable = packageInfo.applicationInfo.loadIcon(mInstance.getPackageManager()); holder.imageView.setBackgroundDrawable(drawable); if (contains(mCheckedList, packageInfo)) { holder.checkBox.setChecked(true); } else { holder.checkBox.setChecked(false); } convertView.setOnClickListener( new OnClickListener() { @Override public void onClick(View view) { if (contains(mCheckedList, packageInfo)) { remove(mCheckedList, packageInfo); } else { mCheckedList.add(packageInfo.packageName); } BlockUtils.save(mInstance, mCheckedList); notifyDataSetChanged(); } }); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Changed to ViewHolder and Picasso error load as per feedback received ViewHolder holder = new ViewHolder(); // Inflate view if it is null if (convertView == null) { convertView = inflater.inflate(R.layout.grid_item, null); holder.imageView = (ImageView) convertView.findViewById(R.id.movie_poster); MovieDetailDO movie = movieList.get(position); convertView.setTag(holder); Picasso.with(context) .load(movie.getPoster_path()) // .placeholder(R.drawable.def_pos) .error(R.drawable.def_pos) .into(holder.imageView); } else { holder.imageView = (ImageView) convertView.findViewById(R.id.movie_poster); MovieDetailDO movie = movieList.get(position); convertView.setTag(holder); Picasso.with(context) .load(movie.getPoster_path()) // .placeholder(R.drawable.def_pos) .error(R.drawable.def_pos) .into(holder.imageView); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { // inflation LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Service.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(this.ressource, parent, false); // initialize view holder viewHolder = new ViewHolder(); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.trackAlbumImageView); viewHolder.trackName = (TextView) convertView.findViewById(R.id.trackNameTextView); viewHolder.albumName = (TextView) convertView.findViewById(R.id.albumNameTextView); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } // update values SSTrack track = getItem(position); if (track.getImageUrl() != null) { picasso.load(track.getImageUrl()).into(viewHolder.imageView); } else { viewHolder.imageView.setImageResource(R.drawable.ic_spotifyicon); } viewHolder.trackName.setText(track.getName()); viewHolder.albumName.setText(track.getAlbumName()); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder view; LayoutInflater inflater = activity.getLayoutInflater(); if (convertView == null) { view = new ViewHolder(); convertView = inflater.inflate(R.layout.activity_main_row, null); if (!hasText) { convertView.findViewById(R.id.mainTextView).setVisibility(View.GONE); } view.imageView = (SquaredImageView) convertView.findViewById(R.id.mainImageView); convertView.setTag(view); } else { view = (ViewHolder) convertView.getTag(); } ImageObject image = images.get(position); String imgUrl = image.getUrl(); // Trigger the download of the URL asynchronously into the image view. Picasso.with(activity) .load(imgUrl) .placeholder(R.drawable.placeholder) .fit() .tag(activity) .into(view.imageView); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if (convertView == null) { convertView = inflater.inflate(R.layout.item_nearbyrestaurant, null); viewHolder = new ViewHolder(); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.item_nearbyrestaurant_img); viewHolder.txtAverage = (TextView) convertView.findViewById(R.id.item_nearbyrestaurant_average); viewHolder.txtAverage.setTypeface(fontFace); viewHolder.txtName = (TextView) convertView.findViewById(R.id.item_nearbyrestaurant_name); viewHolder.txtName.setTypeface(fontFace); viewHolder.txtSpecialty = (TextView) convertView.findViewById(R.id.item_nearbyrestaurant_specialty); viewHolder.txtSpecialty.setTypeface(fontFace); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } Restaurant restaurant = list.get(position); imageLoader.storeLoadImage(restaurant.getImage(), this, viewHolder); viewHolder.txtAverage.setText("人均:" + restaurant.getAverage()); // viewHolder.txtLike.setText(restaurant.getLike() + "人喜欢"); viewHolder.txtName.setText(restaurant.getName()); viewHolder.txtSpecialty.setText("招牌菜:" + restaurant.getSpecialty()); return convertView; }
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; font = Typeface.createFromAsset(this.context.getAssets(), "lato_reg.ttf"); MusicRowItem rowItem = getItem(position); LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = mInflater.inflate(R.layout.music_list, null); holder = new ViewHolder(); holder.txtTitle = (TextView) convertView.findViewById(R.id.title); holder.imageView = (ImageView) convertView.findViewById(R.id.icon); holder.Di = (TextView) convertView.findViewById(R.id.SelectedIcon); // TextView ListTitle = (TextView) convertView.findViewById(R.id.title); holder.txtTitle.setTypeface(font); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); // holder.txtDesc.setText(rowItem.getDesc()); holder.txtTitle.setText(rowItem.getTitle()); holder.imageView.setImageResource(rowItem.getImageId()); // holder.Di.setTypeface(font); /* if(rowItem.getDefault() == true) {*/ holder.Di.setBackgroundResource(R.drawable.notify_pairing); holder.Di.setText("Selected"); holder.Di.setTypeface(font); /*}*/ return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = LayoutInflater.from(mcontext).inflate(R.layout.item_horizaontal_index, null); viewHolder = new ViewHolder(); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView_item_hor_index); viewHolder.textView = (TextView) convertView.findViewById(R.id.text_item_hor_index); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } IndexItemInfo investment = list.get(position); String imageUrl = Url.prePic + investment.getLogo(); String name = investment.getCompany_name(); // Picasso.with(mcontext) // .load(imageUrl) // .into(viewHolder.imageView); imageLoader.displayImage( imageUrl, viewHolder.imageView, MyDisplayImageOptions.getdefaultImageOptions()); // viewHolder.imageView.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Intent intent=new Intent(mcontext, CPDetailActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // mcontext.startActivity(intent); // Activity activity= (Activity) mcontext; // activity.overridePendingTransition(R.anim.in_from_right,R.anim.out_to_left); // } // }); viewHolder.textView.setText(name); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater mInflater = (LayoutInflater) ((Activity) context).getLayoutInflater(); ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.tv_grid_item, null); holder.imageView = (TextView) convertView.findViewById(R.id.videotvbg); holder.textView = (TextView) convertView.findViewById(R.id.videotvName); // courseBeans[position].textView = tv; convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.imageView.setText(videobeans.get(position).videoDetail); if ("".equals(videobeans.get(position).resourceUrl) != true) holder.imageView.setBackgroundDrawable( Drawable.createFromPath(videobeans.get(position).resourceUrl)); else holder.imageView.setBackgroundResource(R.drawable.program_loading_bg); holder.textView.setText(videobeans.get(position).videoName); // convertView.setPadding(0, 15, 0, 15); // Log.i("getView", "+++ postion" + selectedPosition); convertView.setPadding(15, 5, 15, 5); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; UserActivityTypPrx rowItem = getItem(position); LayoutInflater mInflater = (LayoutInflater) _context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = mInflater.inflate(_resource, null); holder = new ViewHolder(); holder.imageView = (ImageView) convertView.findViewById(_imageProjectionView); holder.txtTitle = (TextView) convertView.findViewById(_textProjectionView); holder.txtSubtitle = (TextView) convertView.findViewById(_subtextProjectionView); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); byte[] avatarBytes = null; if (rowItem.getUserActivityType() == ActivityType.TRIPJOIN || rowItem.getUserActivityType() == ActivityType.TRIPREQUESTANSWERED) { List<PassengerTyp> passengers = rowItem.getActivityTrip().getTripPassengers(); avatarBytes = passengers.get(passengers.size() - 1).getPassengerUser().getAvatarBytes(); } else { avatarBytes = rowItem.getActivityTrip().getTripDriver().getAvatarBytes(); } holder.txtTitle.setText(rowItem._toString()); holder.txtSubtitle.setText( SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.SHORT, SimpleDateFormat.MEDIUM) .format(new Date(rowItem.getTimeStampInMillis()))); holder.imageView.setImageBitmap( BitmapFactory.decodeByteArray(avatarBytes, 0, avatarBytes.length)); return convertView; }
@Override public View getView(final int position, View view, ViewGroup container) { ViewHolder holder; if (view == null) { holder = new ViewHolder(); view = holder.imageView = new NetworkImageView(context); holder.imageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { LinkArticle media = imageURLList.get(getPosition(position)); if (!StringUtils.isBlank(media.getLink())) { Intent intent = new Intent(context, ShowWebViewActivity.class); intent.putExtra("title", media.getTitle()); intent.putExtra("url", media.getLink()); context.startActivity(intent); } } }); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } holder.imageView.setScaleType(ScaleType.CENTER_CROP); holder.imageView.setImageUrl( Constants.HOST_IP + imageURLList.get(getPosition(position)).getImgUrl(), ImageCacheManager.getInstance().getImageLoader()); return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { App item = getItem(position); ViewHolder holder; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Service.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.item_app, parent, false); holder = new ViewHolder(); holder.imageView = (ImageView) convertView.findViewById(R.id.image_view); holder.titleTextView = (TextView) convertView.findViewById(R.id.title_text_view); holder.companyTextView = (TextView) convertView.findViewById(R.id.company_text_view); holder.ratingBar = (RatingBar) convertView.findViewById(R.id.rating_bar); holder.valueTextView = (TextView) convertView.findViewById(R.id.value_text_view); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.titleTextView.setText(item.title); holder.companyTextView.setText(item.company); holder.ratingBar.setRating(item.rate); holder.valueTextView.setText("¥" + item.value); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.listview_sign_layout, null); viewHolder = new ViewHolder(); viewHolder.textView = (TextView) convertView.findViewById(R.id.usernameItem); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.currentFlag); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } Map<String, String> map = mData.get(position); String item = map.get(mContext.getString(R.string.sign_detail_key)); String flag = map.get(mContext.getString(R.string.sign_issuccess_key)); boolean is_success = Boolean.valueOf(flag); viewHolder.textView.setText(item); if (is_success) { viewHolder.imageView.setImageResource(R.drawable.ic_check); } else { viewHolder.imageView.setImageResource(R.drawable.ic_close); } long id = getItemId(position); if (!itemAnims.contains(id)) { itemAnims.add(id); convertView.startAnimation(mAnim); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ViewHolder holder; if (convertView == null) { // Log.v("test", "convertView is null"); holder = new ViewHolder(); convertView = inflater.inflate(R.layout.photo, null); holder.imageView = (ImageView) convertView.findViewById(R.id.imageView1); holder.ImageId = (TextView) convertView.findViewById(R.id.imageId); holder.Path = (TextView) convertView.findViewById(R.id.imagePath); convertView.setTag(holder); } else { // Log.v("test", "convertView is not null"); holder = (ViewHolder) convertView.getTag(); } Photo photo = myPhotoList.get(position); holder.ImageId.setText("ImageId : " + photo.getId()); String URL = photo.getThumbpath(); holder.Path.setText("Path : " + photo.getPath()); // Create an object for subclass of AsyncTask GetXMLTask task = new GetXMLTask(); // Execute the task task.execute(new String[] {URL}); holder.imageView.setImageBitmap(myPhoto); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = null; ViewHolder holder = null; if (convertView != null) { view = convertView; } else { view = LayoutInflater.from(context).inflate(R.layout.common_layout, parent, false); } holder = (ViewHolder) view.getTag(); if (holder == null) { holder = new ViewHolder(); holder.imageView = (ImageView) view.findViewById(R.id.common_image); holder.textView = (TextView) view.findViewById(R.id.common_text); holder.button = (Button) view.findViewById(R.id.common_button); view.setTag(holder); } Myself myself01 = (Myself) getItem(position); holder.imageView.setImageResource(myself01.getImageId()); holder.textView.setText(myself01.getName()); return view; }
public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { convertView = layoutInflater.inflate(R.layout.upcoming_row, null); holder = new ViewHolder(); holder.headlineView = (TextView) convertView.findViewById(R.id.txtmovietitle); holder.thumbrating = (TextView) convertView.findViewById(R.id.txtthumbup); holder.imageView = (ImageView) convertView.findViewById(R.id.imgmovie); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } MovieClass newsItem = (MovieClass) listData.get(position); holder.headlineView.setText(newsItem.getHeadline()); holder.thumbrating.setText(newsItem.getThumb() + " want to see this."); if (holder.imageView != null) { new ImageDownloaderTask(holder.imageView).execute(newsItem.getUrl()); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(layoutResource, parent, false); holder = new ViewHolder(); holder.imageView = (ImageView) convertView.findViewById(R.id.image); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } Data imageData = imagesDataList.get(position); Uri uri = Uri.parse(imageData.link); Picasso.with(context) .load(uri) .placeholder(R.mipmap.ic_launcher) .resize(gridSize, gridSize) .into(holder.imageView); return convertView; }
@Override public View getView(int position, View converView, ViewGroup viewGrop) { ViewHolder vh = null; if (converView == null) { vh = new ViewHolder(); converView = LayoutInflater.from(context).inflate(R.layout.item, null); vh.title = (TextView) converView.findViewById(R.id.title); vh.content = (TextView) converView.findViewById(R.id.content); vh.imageView = (ImageView) converView.findViewById(R.id.imageView1); converView.setTag(vh); } else { vh = (ViewHolder) converView.getTag(); } Alpha bean = getItem(position); vh.title.setText(bean.title); vh.content.setText(bean.content); vh.imageView.setImageResource(bean.imageViewId); if (bean.type == Alpha.SECTION) { vh.title.setBackgroundResource(R.drawable.bao_headview_bg); vh.imageView.setVisibility(View.GONE); vh.title.setTextSize(14); vh.content.setVisibility(View.GONE); } else { vh.title.setBackgroundResource(R.drawable.details_layout_bg); vh.imageView.setVisibility(View.VISIBLE); } return converView; }
@SuppressLint("InflateParams") @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { // Inflate layout from layout resource // Passing parent instead of null ends in java.lang.UnsupportedOperationException: // addView(View, LayoutParams) is not supported in AdapterView convertView = mInflater.inflate(R.layout.liked_grid_item, null); viewHolder = new ViewHolder(); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.liked_avatar); viewHolder.textView = (TextView) convertView.findViewById(R.id.liked_name); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } ExoPicasso.picasso(getApplicationContext()) .load(Uri.parse(likeList.get(position).likedImageUrl)) .error(R.drawable.default_avatar) .into(viewHolder.imageView); viewHolder.textView.setText(likeList.get(position).getLikeName()); return convertView; }
@Override public View getView(int arg0, View arg1, ViewGroup arg2) { // TODO Auto-generated method stub ViewHolder holder; LayoutInflater mInflater = (LayoutInflater) LogView.this.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); if (arg1 == null) { arg1 = mInflater.inflate(R.layout.dirctioncustomview, null); holder = new ViewHolder(); holder.txtDesc = (TextView) arg1.findViewById(R.id.step); holder.txtTitle = (TextView) arg1.findViewById(R.id.stepno); holder.imageView = (ImageView) arg1.findViewById(R.id.img); arg1.setTag(holder); } else { holder = (ViewHolder) arg1.getTag(); } holder.txtTitle.setText("Step No. " + (arg0 + 1)); holder.txtDesc.setText(SiteList.Dir_descriptionList.get(arg0)); try { System.out.println("link to disply inside view exc " + SiteList.Dir_imageList.get(arg0)); loader.displayImage(SiteList.Dir_imageList.get(arg0), holder.imageView, options); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return arg1; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); convertView = View.inflate(context, R.layout.setting_choosepicture_gridview_model, null); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.settingChoosePictureModel_Iv); viewHolder.tv = (TextView) convertView.findViewById(R.id.settingChoosePictureModel_selectTv); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } // viewHolder.imageView.setScaleType(ScaleType.FIT_XY); // viewHolder.imageView.setLayoutParams(new LinearLayout.LayoutParams(screenW, screenH)); // ��ͼƬԭʼ�ߴ磬�����Ժ�Ӧ�� int[] parameter = {arrayList.get(position).getWidth(), arrayList.get(position).getHeight()}; viewHolder.imageView.setTag(parameter); viewHolder.imageView.setImageBitmap(arrayList.get(position)); if (onlyselectItem == 0) { viewHolder.tv.setVisibility(View.VISIBLE); } if (position == selectItem) { viewHolder.tv.setVisibility(View.VISIBLE); } else { viewHolder.tv.setVisibility(View.GONE); } if (arrayList.size() == 2) { if (position == 0) { viewHolder.tv.setVisibility(View.VISIBLE); } } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; holder = new ViewHolder(); if (position == 0) { convertView = inflater.inflate(R.layout.profile_navigation, parent, false); holder.name = (TextView) convertView.findViewById(R.id.name); holder.email = (TextView) convertView.findViewById(R.id.email); if (user != null) { holder.name.setText(user.getString("name")); holder.email.setText(user.getEmail()); } else { holder.name.setText("Guest User"); } } else { convertView = inflater.inflate(resourceId, parent, false); holder.nameTxt = (TextView) convertView.findViewById(R.id.text_navigationlist); holder.imageView = (ImageView) convertView.findViewById(R.id.icon_navigationlist); holder.nameTxt.setText(names[position]); holder.imageView.setImageDrawable(icons.getDrawable(position)); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder vh = null; if (position != getCount() - 1) { // 最后一个位置 固定为添加照片的位置 if (convertView == null) { convertView = LayoutInflater.from(context).inflate(R.layout.simple3_grid_item, null); vh = new ViewHolder(); vh.imageView = (ImageView) convertView.findViewById(R.id.iv_addimage_id); vh.delete = (ImageView) convertView.findViewById(R.id.iv_addimage_delete); convertView.setTag(vh); } else { vh = (ViewHolder) convertView.getTag(); } } else { convertView = LayoutInflater.from(context).inflate(R.layout.simple_grid_item, null); vh = new ViewHolder(); vh.imageView = (ImageView) convertView.findViewById(R.id.image); vh.delete = null; convertView.setTag(vh); } final int index = position; vh.imageView.setImageResource((Integer) members.get(position).get("image")); if (position == getCount() - 1) { vh.imageView.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // 添加照片 并跳转到原来的页面 ToastUtil.showTextLong(context, "添加图片"); } }); } else { if (vh.delete != null) { vh.delete.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { members.remove(index); AddImageByAdapter.this.notifyDataSetChanged(); // 更新UI,因为与UI不是同线程 } }); } } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { Photo photo = getItem(position); ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); convertView = LayoutInflater.from(getContext()).inflate(R.layout.photo_item, parent, false); viewHolder.userName = (TextView) convertView.findViewById(R.id.tv_username); viewHolder.caption = (TextView) convertView.findViewById(R.id.tv_caption); viewHolder.imageView = (ImageView) convertView.findViewById(R.id.iv_photo); viewHolder.profileImage = (RoundedImageView) convertView.findViewById(R.id.iv_profile); viewHolder.likes = (TextView) convertView.findViewById(R.id.tv_likes); viewHolder.relativeTime = (TextView) convertView.findViewById(R.id.tv_time); viewHolder.lastComment = (TextView) convertView.findViewById(R.id.tv_lastComment); viewHolder.secondLastComment = (TextView) convertView.findViewById(R.id.tv_secondLastComment); viewHolder.lastCommenterName = (TextView) convertView.findViewById(R.id.tv_lastCommenterName); viewHolder.secondLastCommenterName = (TextView) convertView.findViewById(R.id.tv_secondLastCommenterName); viewHolder.totalComments = (TextView) convertView.findViewById(R.id.tv_totalComments); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } final ProgressBar progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar); progressBar.setVisibility(View.VISIBLE); viewHolder.userName.setText(photo.getUserName()); viewHolder.caption.setText(photo.getCaption()); String heartText = getContext().getResources().getString(R.string.heart_label); viewHolder.likes.setText(heartText + " " + photo.getLikes() + " likes"); viewHolder.totalComments.setText(photo.getCommentsCount() + " Comment"); viewHolder.relativeTime.setText(photo.getTime()); viewHolder.lastComment.setText(photo.getLastComment()); viewHolder.secondLastComment.setText(photo.getSecondLastComment()); viewHolder.lastCommenterName.setText(photo.getLastCommenterName() + ":"); viewHolder.secondLastCommenterName.setText(photo.getSecondLastCommenterName() + ":"); viewHolder.imageView.setImageResource(0); Picasso.with(getContext()) .load(photo.getUrl()) .into( viewHolder.imageView, new Callback() { @Override public void onSuccess() { progressBar.setVisibility(View.GONE); } @Override public void onError() {} }); Picasso.with(getContext()).load(photo.getProfilePictureUrl()).into(viewHolder.profileImage); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { final View aView; if (convertView == null) { final ViewHolder viewHolder = new ViewHolder(); aView = getLayoutInflater().inflate(R.layout.item_category_grid, parent, false); viewHolder.imageView = (ImageView) aView.findViewById( R.id .image_item_category); // (ImageView) // getLayoutInflater().inflate(R.layout.item_grid_image, parent, false); viewHolder.weView = (WebView) aView.findViewById( R.id .web); // (ImageView) getLayoutInflater().inflate(R.layout.item_grid_image, // parent, false); int ww = viewHolder.imageView.getLayoutParams().width = (ConstantValues.DEVICE_WIDTH / 3) - 3; int wh = viewHolder.imageView.getLayoutParams().height = (int) (((ConstantValues.DEVICE_WIDTH / 2) * 0.75) - 2); String h = Html.replace("ximgurl", imageUrls[position]) .replace("xW", ww + "") .replace("xH", wh + ""); viewHolder.weView.loadData(h, "text/html; charset=UTF-8", null); viewHolder.textView = (TextView) aView.findViewById(R.id.text_item_cat_desc); viewHolder.textView.setText(Imageurl.title.get(position)); // viewHolder.imageView.setMaxWidth(150); imageLoader.displayImage( imageUrls[position], viewHolder.imageView, options, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(Bitmap loadedImage) { Animation anim = AnimationUtils.loadAnimation(CategoryGridActivity.this, R.anim.fade_in); viewHolder.imageView.setAnimation(anim); anim.start(); } }); } else { aView = convertView; } return aView; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder holder; CmMatch cmMatch = mCmItems.get(position); View view = convertView; int imageId = 0; if (null == view) { LayoutInflater inflater = LayoutInflater.from(mActivity); view = inflater.inflate(R.layout.row_adapter_cm_list, parent, false); holder = new ViewHolder(); holder.imageView = (ImageView) view.findViewById(R.id.image_cm_item); holder.textView = (TextView) view.findViewById(R.id.textview_cm); holder.textViewInfo = (TextView) view.findViewById(R.id.textview_user_info); holder.imageViewReason1 = (ImageView) view.findViewById(R.id.image_cm_reason1); holder.imageViewReason2 = (ImageView) view.findViewById(R.id.image_cm_reason2); holder.imageViewReason3 = (ImageView) view.findViewById(R.id.image_cm_reason3); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } imageId = UiHelpers.getCmImageId(cmMatch.getCmIdx()); if (R.drawable.transparent != imageId) { holder.imageView.setImageDrawable(mActivity.getResources().getDrawable(imageId)); } else { holder.imageView.setVisibility(View.GONE); } CmIdx cmIdx = CmIdxItems.getCmIdx(cmMatch.getCmIdx()); String cmString = cmIdx.getCmString(); holder.textView.setText(cmString); if (null == cmMatch.getCmInfoString()) { holder.textViewInfo.setVisibility(View.GONE); } else { String cmInfo = cmMatch.getCmInfoString(); holder.textViewInfo.setText(cmInfo); } if (null == cmMatch.getCmReasons()) { holder.imageViewReason1.setVisibility(View.GONE); holder.imageViewReason2.setVisibility(View.GONE); holder.imageViewReason3.setVisibility(View.GONE); } else { imageId = UiHelpers.getStateImageId(cmMatch.getCmReasons()[0]); if (R.drawable.transparent != imageId) { holder.imageViewReason1.setImageDrawable(mActivity.getResources().getDrawable(imageId)); } else holder.imageViewReason1.setVisibility(View.GONE); imageId = UiHelpers.getStateImageId(cmMatch.getCmReasons()[1]); if (R.drawable.transparent != imageId) { holder.imageViewReason2.setImageDrawable(mActivity.getResources().getDrawable(imageId)); } else holder.imageViewReason2.setVisibility(View.GONE); imageId = UiHelpers.getStateImageId(cmMatch.getCmReasons()[2]); if (R.drawable.transparent != imageId) { holder.imageViewReason3.setImageDrawable(mActivity.getResources().getDrawable(imageId)); } else holder.imageViewReason3.setVisibility(View.GONE); } return view; }
// 맨 처음 레이아웃 만드는 부분 @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { // 레이아웃 가져오기 View view = mLayoutInflater.inflate(R.layout.item_picture, parent, false); // 홀더에 저장 ViewHolder holder = new ViewHolder(); holder.imageView = (ImageView) view.findViewById(R.id.imageView); view.setTag(holder); return view; }
@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.activity_googlecards_card, parent, false); viewHolder = new ViewHolder(); viewHolder.textView = (TextView) view.findViewById(R.id.activity_googlecards_card_textview); viewHolder.textView_mail = (TextView) view.findViewById(R.id.activity_googlecards_card_mail); viewHolder.textView_git = (TextView) view.findViewById(R.id.activity_googlecards_card_github); view.setTag(viewHolder); viewHolder.imageView = (ImageView) view.findViewById(R.id.activity_googlecards_card_imageview); } else { viewHolder = (ViewHolder) view.getTag(); } viewHolder.textView.setText("This is card " + (getItem(position) + 1)); switch (position) { case 0: viewHolder.textView.setText("Arpith"); viewHolder.textView_mail.setText("*****@*****.**"); viewHolder.textView_git.setText("github.com/arpith20"); break; case 1: viewHolder.textView.setText("Gregoire Decorvet"); viewHolder.textView_mail.setText("*****@*****.**"); viewHolder.textView_git.setText("github.com/GregoireDec"); break; case 2: viewHolder.textView.setText("Nagabharan N"); viewHolder.textView_mail.setText("*****@*****.**"); viewHolder.textView_git.setText("github.com/nagabharan"); break; case 3: viewHolder.textView.setText("Thomas Schweizer"); viewHolder.textView_mail.setText("*****@*****.**"); viewHolder.textView_git.setText("github.com/Thomas-Sch"); break; } setImageView(viewHolder, position); return view; }
@Override public View getView(int i, View view, ViewGroup viewGroup) { if (view == null) { view = View.inflate(HomeActivity.this, R.layout.activity_home_gridview_simple_item, null); ViewHolder viewHolder = new ViewHolder(); viewHolder.imageView = (ImageView) view.findViewById(R.id.imageview); viewHolder.textView = (TextView) view.findViewById(R.id.textview); view.setTag(viewHolder); } ViewHolder viewHolder = (ViewHolder) view.getTag(); viewHolder.imageView.setImageResource(Modules.moduleIconRes[modules.get(i).getIconid()]); viewHolder.textView.setText(modules.get(i).getName()); return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = LayoutInflater.from(mContext) .inflate(Res.getLayoutID("plugin_camera_select_folder"), null); holder = new ViewHolder(); holder.backImage = (ImageView) convertView.findViewById(Res.getWidgetID("file_back")); holder.imageView = (ImageView) convertView.findViewById(Res.getWidgetID("file_image")); holder.choose_back = (ImageView) convertView.findViewById(Res.getWidgetID("choose_back")); holder.folderName = (TextView) convertView.findViewById(Res.getWidgetID("name")); holder.fileNum = (TextView) convertView.findViewById(Res.getWidgetID("filenum")); holder.imageView.setAdjustViewBounds(true); // LinearLayout.LayoutParams lp = new // LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,dipToPx(65)); // lp.setMargins(50, 0, 50,0); // holder.imageView.setLayoutParams(lp); holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); String path; if (AlbumActivity.contentList.get(position).imageList != null) { // path = photoAbsolutePathList.get(position); // 封面图片路径 path = AlbumActivity.contentList.get(position).imageList.get(0).imagePath; // 给folderName设置值为文件夹名称 // holder.folderName.setText(fileNameList.get(position)); holder.folderName.setText(AlbumActivity.contentList.get(position).bucketName); // 给fileNum设置文件夹内图片数量 // holder.fileNum.setText("" + fileNum.get(position)); holder.fileNum.setText("" + AlbumActivity.contentList.get(position).count); } else path = "android_hybrid_camera_default"; if (path.contains("android_hybrid_camera_default")) holder.imageView.setImageResource(Res.getDrawableID("plugin_camera_no_pictures")); else { // holder.imageView.setImageBitmap( // AlbumActivity.contentList.get(position).imageList.get(0).getBitmap()); final ImageItem item = AlbumActivity.contentList.get(position).imageList.get(0); holder.imageView.setTag(item.imagePath); cache.displayBmp(holder.imageView, item.thumbnailPath, item.imagePath, callback); } // 为封面添加监听 holder.imageView.setOnClickListener( new ImageViewClickListener(position, mIntent, holder.choose_back)); return convertView; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; final VideoInfo f = getItem(position); if (convertView == null) { convertView = createConvertView(position); viewHolder = new ViewHolder(); viewHolder.delete = (Button) convertView.findViewById(R.id.right_back_delete); viewHolder.title = ((TextView) convertView.findViewById(R.id.video_title)); viewHolder.time = ((TextView) convertView.findViewById(R.id.video_time)); viewHolder.size = ((TextView) convertView.findViewById(R.id.video_size)); viewHolder.imageView = ((ImageView) convertView.findViewById(R.id.video_img)); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.title.setText(f.displayName); viewHolder.time.setText(f.time); viewHolder.size.setText(f.Size); Bitmap bitmap = BitmapUtils.decodeBitmapFromSDCard(f.thumb_path, 80, 80); // 如果本地缓存图片被删除了,重新获取缩略图 if (bitmap != null) { viewHolder.imageView.setImageBitmap(bitmap); } else { bitmap = getVideoThumbnail(f.path, 80, 80, MediaStore.Video.Thumbnails.MINI_KIND); if (bitmap == null) bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.default_video_img); // 默认图片 viewHolder.imageView.setImageBitmap(bitmap); } if (viewHolder.delete != null) { viewHolder.delete.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mDbHelper.remove(mVideoList.get(position)); mVideoList.remove(position); notifyDataSetChanged(); } }); } return convertView; }