@Override public View getView(int position, View convertView, ViewGroup arg2) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.item_gallery, null); holder.mImageView = (SqureImageView) convertView.findViewById(R.id.squreImageView); holder.mTextName = (TextView) convertView.findViewById(R.id.textImageName); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } StoredImageBo mageBo = mFilePaths.get(position); File file = new File(mageBo.getmImagePath()); if (file.isFile()) { Bitmap myBitmap = BitmapFactory.decodeFile(mageBo.getmImagePath()); holder.mImageView.setImageBitmap(myBitmap); } else { Bitmap myBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.images_not_found); holder.mImageView.setImageBitmap(myBitmap); } holder.mTextName.setText(mageBo.getmImageName()); return convertView; }
// 获取显示当前的view @Override public View getView(int i, View view, ViewGroup viewgroup) { ViewHolder holder = null; if (view == null) { view = getLayoutInflater().inflate(R.layout.weixinpage3_item, viewgroup, false); holder = new ViewHolder(); holder.mImageView = (ImageView) view.findViewById(R.id.video_preview_img); holder.mName = (TextView) view.findViewById(R.id.txt_video_caption); holder.mName1 = (TextView) view.findViewById(R.id.TextView03); holder.mYear = (TextView) view.findViewById(R.id.txt_1); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } // 获取当前数据项的数据 Tab3Page1ListData m_Tab3Page1ListData = (Tab3Page1ListData) getItem(i); AQuery aqlist = aq.recycle(view); aqlist.id(holder.mName).text(m_Tab3Page1ListData.Pro_name); aqlist.id(holder.mName1).text(stringForTime(m_Tab3Page1ListData.Pro_duration)); aqlist.id(holder.mYear).visible(); aqlist.id(holder.mImageView).image(m_Tab3Page1ListData.Pro_pic_url, true, true); return view; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.list_itemforshare, null); viewHolder = new ViewHolder(); viewHolder.mTextView = (TextView) convertView.findViewById(R.id.item_tips1); viewHolder.mImageView = (ImageView) convertView.findViewById(R.id.iv_image1); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } String url = ""; url = urlArrays[position % urlArrays.length]; viewHolder.mImageView.setImageResource(R.drawable.ic_launcher); if (!mBusy) { mImageLoader.DisplayImage(url, viewHolder.mImageView, false); viewHolder.mTextView.setText("--" + position + "--IDLE ||TOUCH_SCROLL"); } else { mImageLoader.DisplayImage(url, viewHolder.mImageView, false); viewHolder.mTextView.setText("--" + position + "--FLING"); } return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub View vi = convertView; ViewHolder holder; if (convertView == null) { vi = inflater.inflate(R.layout.custom_row_network, null); holder = new ViewHolder(); holder.mImageView = (ImageView) vi.findViewById(R.id.icon); holder.mTextView1 = (TextView) vi.findViewById(R.id.secondLine); holder.mTexview2 = (TextView) vi.findViewById(R.id.thirdLine); /** ********** Set holder with LayoutInflater *********** */ vi.setTag(holder); } else { holder = (ViewHolder) vi.getTag(); } if (listVisibleAccessPoint.size() <= 0) { holder.mTextView1.setText("No Data"); } else { mAccesspoint = null; mAccesspoint = listVisibleAccessPoint.get(position); /** ********** Set Model values in Holder elements ********** */ holder.mImageView = (ImageView) vi.findViewById(R.drawable.abc_ab_bottom_solid_light_holo); // holder.mImageView.setImageResource(res.getIdentifier("com.androidexample.customlistview:drawable/"+tempValues.getImage(),null,null)); holder.mTextView1.setText("" + mAccesspoint.getSsid() + " Mac: " + mAccesspoint.getBssid()); holder.mTexview2.setText("Strength: " + mAccesspoint.getLevel() * -1 + "%"); /** ****** Set Item Click Listner for LayoutInflater for each row ****** */ vi.setOnClickListener(new OnItemClickListener(position)); } return vi; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder viewHolder; final String path = list.get(position); if (convertView == null) { convertView = mInflater.inflate(R.layout.grid_photo_select_child_item, null); viewHolder = new ViewHolder(); viewHolder.mImageView = (OnMeasureImageView) convertView.findViewById(R.id.child_image); viewHolder.mCheckBox = (TextView) convertView.findViewById(R.id.child_checkbox); // 用来监听ImageView的宽和高 viewHolder.mImageView.setOnMeasureListener( new OnMeasureListener() { @Override public void onMeasureSize(int width, int height) { mPoint.set(width, height); } }); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); viewHolder.mImageView.setImageResource(R.drawable.default_album_pictures); } viewHolder.mImageView.setTag(path); viewHolder.mCheckBox.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { int size = have_select_photos_list.size(); if (have_select_photos_list.contains(path)) { // 多次相册选择情况 isChecked = false; } else { isChecked = !mSelectMap.get(position); // 判断是否超出最大选择图片张数限制 boolean flag = !mSelectMap.containsKey(position) || !mSelectMap.get(position); if (size >= UFunConstants.MAX_CHOICE_PHOTO_NUM && flag) { String tip = String.format( mContext.getString(R.string.max_choice_photo_num_tip), UFunConstants.MAX_CHOICE_PHOTO_NUM); UIHelper.ToastMessage(mContext, tip); viewHolder.mCheckBox.setBackgroundResource( R.drawable.pictures_multiple_choice_icon_unselected); return; } // 如果是未选中的CheckBox,则添加动画 if (flag) { addAnimation(viewHolder.mCheckBox); } } mSelectMap.put(position, isChecked); if (isChecked) { if (!have_select_photos_list.contains(path)) { have_select_photos_list.add(path); } viewHolder.mCheckBox.setText(size + ""); viewHolder.mCheckBox.setBackgroundResource( R.drawable.pictures_multiple_choice_icon_selected); } else { if (have_select_photos_list.contains(path)) { have_select_photos_list.remove(path); } viewHolder.mCheckBox.setText(""); viewHolder.mCheckBox.setBackgroundResource( R.drawable.pictures_multiple_choice_icon_unselected); } if (mContext instanceof PhotoImageSelectActivity) { ((PhotoImageSelectActivity) mContext).refreshChoiceBtnText(); } notifyDataSetChanged(); } }); if (have_select_photos_list.contains(path)) { for (int i = 0; i < have_select_photos_list.size(); i++) { if (have_select_photos_list.get(i).equals(path)) { viewHolder.mCheckBox.setText((i + 1) + ""); viewHolder.mCheckBox.setBackgroundResource( R.drawable.pictures_multiple_choice_icon_selected); } } } else { viewHolder.mCheckBox.setText(""); viewHolder.mCheckBox.setBackgroundResource( R.drawable.pictures_multiple_choice_icon_unselected); } // 利用NativeImageLoader类加载本地图片 Bitmap bitmap = NativeImageLoader.getInstance() .loadNativeImage( path, mPoint, new NativeImageCallBack() { @Override public void onImageLoader(Bitmap bitmap, String path) { ImageView mImageView = (ImageView) mGridView.findViewWithTag(path); if (bitmap != null && mImageView != null) { mImageView.setImageBitmap(bitmap); } } }); if (bitmap != null) { viewHolder.mImageView.setImageBitmap(bitmap); } else { viewHolder.mImageView.setImageResource(R.drawable.default_album_pictures); } viewHolder.mImageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, ViewImageActivity.class); Bundle bundle = new Bundle(); // List<String> mUrls = new ArrayList<String>(); // for (int i = 0; i < mUrls.size(); i++) { // mUrls.add("file:///"+list.get(i).toString()); // } bundle.putStringArray("urls", list.toArray(new String[] {})); bundle.putInt("index", position); bundle.putSerializable("ViewType", ViewType.Select); bundle.putStringArrayList("have_select_photos_list", have_select_photos_list); intent.putExtras(bundle); ((Activity) mContext) .startActivityForResult(intent, CommonPhotoSelectActivity.FISHPHOTOLOCAL); } }); return convertView; }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final ViewHolder viewHolder; String path = list.get(position); if (convertView == null) { convertView = mInflater.inflate(R.layout.grid_child_item, null); viewHolder = new ViewHolder(); viewHolder.mImageView = (MyImageView) convertView.findViewById(R.id.child_image); viewHolder.mCheckBox = (CheckBox) convertView.findViewById(R.id.child_checkbox); viewHolder.tv = (TextView) convertView.findViewById(R.id.child_tv); viewHolder.mImageView.setOnMeasureListener( new MyImageView.OnMeasureListener() { @Override public void onMeasureSize(int width, int height) { mPoint.set(width, height); } }); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); viewHolder.mImageView.setImageResource(R.drawable.ic_launcher); } viewHolder.tv.setText("编号:" + Tool.getSaveTime(list.get(position).toString())); viewHolder.mImageView.setTag(path); viewHolder.mCheckBox.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { viewHolder.mCheckBox.setButtonDrawable(R.mipmap.icon_select); } else { viewHolder.mCheckBox.setButtonDrawable(R.mipmap.icon_unselect); } } }); viewHolder.mImageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Intent intent = new Intent(Intent.ACTION_VIEW); // intent.setData(uri); // context.startActivity(intent); } }); viewHolder.mCheckBox.setChecked( mSelectMap.containsKey(position) ? mSelectMap.get(position) : false); Bitmap bitmap = LoacalImageLoader.getInstance() .loadNativeImage( path, mPoint, new LoacalImageLoader.NativeImageCallBack() { @Override public void onImageLoader(Bitmap bitmap, String path) { ImageView mImageView = (ImageView) mGridView.findViewWithTag(path); if (bitmap != null && mImageView != null) { mImageView.setImageBitmap(bitmap); } } }); if (bitmap != null) { viewHolder.mImageView.setImageBitmap(bitmap); } else { viewHolder.mImageView.setImageResource(R.drawable.ic_launcher); } return convertView; }