@Override public View getView(final int position, View convertView, ViewGroup parent) { Holder holder = null; if (convertView == null) { holder = new Holder(); convertView = inflater.inflate(R.layout.good_report_item, null); holder.handImg = (ImageView) convertView.findViewById(R.id.iv_goodbg_hand); holder.title = (TextView) convertView.findViewById(R.id.tv_goodbg_title); holder.aName = (TextView) convertView.findViewById(R.id.tv_goodbg__aname); holder.price = (TextView) convertView.findViewById(R.id.tv_goodbg_price); holder.body = (TextView) convertView.findViewById(R.id.tv_goodbg_text); holder.download = (ImageButton) convertView.findViewById(R.id.ib_bg_download); convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); } final Report report = data.get(position); holder.handImg.setTag(report.getPpath()); // holder.handImg.setImageResource(Integer.parseInt(data.get(position).get("hand").toString())); holder.title.setText(report.getName()); holder.aName.setText(report.getAuthor()); holder.price.setText(report.getPrice()); holder.body.setText(report.getIntro()); ImageResourse imageResource = new ImageResourse(); imageResource.setIconUrl(data.get(position).getPpath() + "/big.png"); imageResource.setIconId(report.getId()); imageResource.setIconTime(report.getProtime()); asyncImageLoader.loadDrawable( imageResource, new ImageCallback() { @Override public void imageLoaded(Drawable imageDrawable, String imageUrl) { ImageView img = (ImageView) goodList.findViewWithTag(report.getPpath()); if (img != null && imageDrawable != null) { // img.setLayoutParams(new Gallery.LayoutParams(360, 160)); img.setScaleType(ImageView.ScaleType.FIT_CENTER); img.setImageDrawable(imageDrawable); } } }); holder.download.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) {} }); return convertView; }
public View getView(final int position, View convertView, ViewGroup parent) { final ProgressBar bar; final TextView tv; Holder holder = null; if (convertView == null) { holder = new Holder(); convertView = inflater.inflate(R.layout.yjbg_book_shelf_item, null); holder.handImg = (ImageView) convertView.findViewById(R.id.yjbg_book_shelf_hand_img); holder.title = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_title); holder.aName = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_aname); holder.price = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_price); holder.body = (TextView) convertView.findViewById(R.id.yjbg_book_shelf_text); convertView.setTag(holder); } else { holder = (Holder) convertView.getTag(); } final Report report = data.get(position); holder.handImg.setTag(report.getPpath()); holder.handImg.setImageResource(R.drawable.report1); holder.title.setText(report.getName()); holder.aName.setText(report.getAuthor()); holder.price.setText(report.getPrice()); if (report.getIntro().length() > 100) { holder.body.setText(report.getIntro().replace("\n", "").subSequence(0, 100) + "..."); } else { holder.body.setText(report.getIntro().replace("\n", "")); } ImageResourse imageResource = new ImageResourse(); imageResource.setIconUrl(data.get(position).getSmallPpath().replace("/big.png", "")); imageResource.setIconId(data.get(position).getId()); imageResource.setIconTime(data.get(position).getProtime()); if (drawables.containsKey(report.getSmallPpath().replace("/big.png", "")) && drawables.get(report.getSmallPpath().replace("/big.png", "")) != null) { holder.handImg.setImageDrawable( drawables.get(report.getSmallPpath().replace("/big.png", ""))); Log.i("view", position + "起作用了"); } else { asyncImageLoader.loadDrawable( imageResource, new ImageCallback() { @Override public void imageLoaded(Drawable imageDrawable, String imageUrl) { ImageView img = (ImageView) listView.findViewWithTag(report.getPpath()); if (img != null && imageDrawable != null) { // img.setLayoutParams(new Gallery.LayoutParams(360, 160)); drawables.put(report.getSmallPpath().replace("/big.png", ""), imageDrawable); img.setScaleType(ImageView.ScaleType.FIT_CENTER); img.setImageDrawable(imageDrawable); } } }); } tv = (TextView) convertView.findViewById(R.id.yjbg_book_list_item_tv); bar = (ProgressBar) convertView.findViewById(R.id.yjbg_book_list_item_pro); /*if (!report.getIsLoad().equals("yes")) { tv.setVisibility(View.VISIBLE); bar.setVisibility(View.VISIBLE); Handler handler = new Handler() { @Override public void handleMessage(Message msg) { bar.setProgress(msg.arg1); tv.setText(msg.arg1 + "%"); if (msg.arg1 == 100) { tv.setText("100%"); report.setIsLoad("yes"); dataHelper.UpdateReportZT(report); } } }; String path = report.getDownpath().toString(); File savedir = new File(Report.SD_PATH+ report.getName()); // Environment.getExternalStorageDirectory().getAbsolutePath() + "/cei/bg/" if (!savedir.exists()) { savedir.mkdirs(); } try { NewFileDownload.download(path, savedir, handler); } catch (Exception e) { e.printStackTrace(); } }*/ if (report.getIsLoad().equals("yes")) { tv.setText("100%"); } return convertView; }