Android开发之ListView实现Item局部刷新

2019-12-10 19:58:37王冬梅
  • holder.statusIcon = (DownloadPercentView) view.findViewById(R.id.status_icon);  holder.name = (TextView) view.findViewById(R.id.name); 
  • holder.downloadPercent = (TextView) view.findViewById(R.id.download_percent);  holder.progressBar = (ProgressBar) view.findViewById(R.id.progressbar); 
  • setData(holder, itemIndex);  } 
  • /**  * 根据状态设置图标 
  • * @param downloadPercentView  * @param status 
  • */  private void setIconByStatus(DownloadPercentView downloadPercentView, AppContent.Status status) { 
  • downloadPercentView.setVisibility(View.VISIBLE);  if(status == AppContent.Status.PENDING) { 
  • downloadPercentView.setStatus(DownloadPercentView.STATUS_PEDDING);  } 
  • if(status == AppContent.Status.DOWNLOADING) {  downloadPercentView.setStatus(DownloadPercentView.STATUS_DOWNLOADING); 
  • }  if(status == AppContent.Status.WAITING) { 
  • downloadPercentView.setStatus(DownloadPercentView.STATUS_WAITING);  } 
  • if(status == AppContent.Status.PAUSED) {  downloadPercentView.setStatus(DownloadPercentView.STATUS_PAUSED); 
  • }  if(status == AppContent.Status.FINISHED) { 
  • downloadPercentView.setStatus(DownloadPercentView.STATUS_FINISHED);  } 
  • }  private class ViewHolder { 
  • private DownloadPercentView statusIcon;  private TextView name; 
  • private TextView downloadPercent;  private ProgressBar progressBar; 
  • }  }