title: Refresh list view data with viewHolder
body: <p>I'm working on a project that has a list view should update automatically with database changes, I'm working on it for a long time and find a solution that using ViewHolder pattern, and I tried this way and it's work really! but now I try manyyyy solution to do it again, it's not working!! pls help me or tell me if there is a tip in using this pattern.
  Thanks really!</p>
  
  <pre><code>public class DownloadItem_ViewHolder {
  
  private boolean hasInited = false;
  public DownloadItem_ViewHolder() {
  
  }
  public DownloadItem_ViewHolder(View convertView) {
      if (convertView != null) {
          App_icon = (ImageView) convertView
                  .findViewById(R.id.Download_app_icon);
          App_name = (TextView) convertView
                  .findViewById(R.id.Downlaod_app_name);
          Downloaded_percent = (TextView) convertView
                  .findViewById(R.id.Downloaded_app_percent);
          Downloaded_progress = (ProgressBar) convertView
                  .findViewById(R.id.Downloaded_app_progress);
          Pause_btn = (ImageView) convertView
                  .findViewById(R.id.Download_pause_btn);
          Resume_btn = (ImageView) convertView
                  .findViewById(R.id.Download_Resume_btn);
          hasInited = true;
      }
  }
  public void setPorgress(int progress) {
      Downloaded_progress.setProgress(progress);
      // Downloaded_percent.setText(String.valueOf(progress) + "%");
  }
  public void setData(DownloadManagerItem_Cls dlItem) {
      if (hasInited) {
          // this.App_icon.setBackground(newDownloadManager.getDownloadItemApp(
          // dlItem.getItemID()).getAppIcon());
          // App_name.setText(newDownloadManager.getDownloadItemApp(
          // dlItem.getItemID()).getAppName()
          // + "--&gt;" + dlItem.getItemID());
          this.Downloaded_progress
                  .setProgress(dlItem.getDownloadPercentage());
          // this.Downloaded_percent.setText(String.valueOf(dlItem
          // .getDownloadPercentage()) + "%");
          // DownloadStatus downloadItemStatus = dlItem.getDownloadStatus();
          // // PAUSE
          // if (downloadItemStatus.equals(DownloadStatus.Pause)) {
          // // Resume
          // Resume_btn.setVisibility(View.VISIBLE);
          // // Pause
          // Pause_btn.setVisibility(View.GONE);
          // } else if (downloadItemStatus.equals(DownloadStatus.Downloading))
          // {// Resume
          // Resume_btn.setVisibility(View.GONE);
          // // Pause
          // Pause_btn.setVisibility(View.VISIBLE);
          // } else if (downloadItemStatus.equals(DownloadStatus.Complete)) {
          // // Resume
          // Resume_btn.setVisibility(View.GONE);
          // // Pause
          // Pause_btn.setVisibility(View.GONE);
          // // Install or Run
          // }
      }
  }
  ImageView App_icon;
  public TextView App_name;
  ProgressBar Downloaded_progress;
  TextView Downloaded_percent;
  public ImageView Resume_btn;
  public ImageView Pause_btn;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class DownloadItemAdpater extends ArrayAdapter&lt;DownloadManagerItem_Cls&gt; {
  
  int _rowResourceID;
  public DownloadItemAdpater(Context context, int rowResourceID,
          List&lt;DownloadManagerItem_Cls&gt; DownloadedItems) {
      super(context, rowResourceID, DownloadedItems);
      _rowResourceID = rowResourceID;
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      // final int AppID = DownloadManager.DownloadedList.get(position).ApkID;
      if (convertView == null) {
          LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                  Context.LAYOUT_INFLATER_SERVICE);
          convertView = vi.inflate(R.layout.download_history_item, null);
          // store the holder with the view.
          // convertView.setTag(1, viewHolder);
  
      }
      convertView.setTag(getItem(position).getItemID());
      DownloadItem_ViewHolder viewHolder = new DownloadItem_ViewHolder(
              convertView);
  
      viewHolder.setData(getItem(position));
      viewHolder.App_name.setText(String.valueOf(getItem(position)
              .getItemID()));
      // set data
      // viewHolder.Pause_btn.setOnClickListener(new DownloadBtnListener(
      // position, viewHolder));
      // viewHolder.Resume_btn.setOnClickListener(new DownloadBtnListener(
      // position, viewHolder));
      return convertView;
  }
  
  public class DownloadManager_Act extends ListActivity {
  DownloadItemAdpater dlAdapter;
  ArrayList&lt;DownloadManagerItem_Cls&gt; listHistory;
  // @Override
  // protected void onDestroy() {
  // unregisterReceiver(mReceiver);
  // super.onDestroy();
  // }
  MyReceiver mReceiver;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dl_manager);
      listHistory = CP_Connector.GDM_QueueTable_Connector.getDownloadList();
      dlAdapter = new DownloadItemAdpater(getApplicationContext(),
              R.layout.download_history_item, listHistory);
      setListAdapter(dlAdapter);
      mReceiver = new MyReceiver();
      IntentFilter filter = new IntentFilter();
      filter.addAction("com.glx.appscenter.dlmanager");
      registerReceiver(mReceiver, filter);
  }
  
  public class MyReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          if (intent != null
                  &amp;&amp; intent.getAction()
                          .equals("com.glx.appscenter.dlmanager")) {
              try {
                  int dlItemID = Integer.valueOf(intent
                          .getStringExtra("itemID"));
                  if (dlItemID &gt;= 0) {
  
                      DownloadManagerItem_Cls dlTempItem = CP_Connector.GDM_QueueTable_Connector
                              .getDownloadItemByID(dlItemID);
                      View v = getListView().findViewWithTag(
                              dlTempItem.getItemID());
                      TextView tv = (TextView) v
                              .findViewById(R.id.Downlaod_app_name);
                      Utility.appUtility.ShowToast(String.valueOf(tv
                              .getText() + ":" + dlItemID));
                      DownloadItem_ViewHolder viewHolder = new DownloadItem_ViewHolder(
                              v);
                      viewHolder.setPorgress(dlTempItem
                              .getDownloadPercentage());
                      dlAdapter.notifyDataSetChanged();
                  }
              } catch (Exception e) {
              }
  
          }
      }
  }
  </code></pre>
  
  <p>}</p>