title: updating a particular item in a custom list in android
body: <p>In my android app, i used custom list to display a log, which contain a phone no and send status as items.  When i send a sms to a phone no, i updates phone and status as pending.
  When the sms delivered, i want to update status as delivered for a particular customer.  how to do this.  Please find code i used for my application</p>
  
  <p>thank you</p>
  
  <p><strong>myactivity</strong></p>
  
  <pre><code>public class MainActivity extends Activity {
  private ListView listview1;
  private Vector&lt;Data&gt; datas = null;
  private DataAdapter adapter = null; 
  private int clickCounter = 0;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      datas = new Vector&lt;Data&gt;();
      adapter = new DataAdapter(this, R.layout.listview_item_row, datas);
      listview1 = (ListView)findViewById(R.id.listView1);
      View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);
      listview1.setAdapter(adapter);
   }
  
  public void sendSMS() {
      Data data1 = new Data(R.drawable.ic_launcher, "987654321", "Pending");
      datas.add(0, data1);
      adapter.notifyDataSetChanged();
  }
  }
  </code></pre>
  
  <p><strong>DataAdapter class</strong></p>
  
  <pre><code>public class DataAdapter extends ArrayAdapter&lt;Data&gt;{
  Context context;
  int layoutResouceId;
  Vector&lt;Data&gt; datas = null;
  
  public DataAdapter(Context context, int layoutResourceId, Vector&lt;Data&gt; datas){
      super(context, layoutResourceId, datas);
      this.context = context;
      this.layoutResouceId = layoutResourceId;
      this.datas = datas;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      DataHolder holder = null;
  
      if( row == null ){
          LayoutInflater inflater = ((Activity)context).getLayoutInflater();
          row = inflater.inflate(layoutResouceId, parent, false);
  
          holder = new DataHolder();
          holder.phoneno = (TextView)row.findViewById(R.id.phoneno);
          holder.status = (TextView)row.findViewById(R.id.status);
  
          row.setTag(holder);
      }
      else {
          holder = (DataHolder)row.getTag();
      }
  
      Data data = datas.get(position);
      holder.txtPhoneno.setText(data.title);
      holder.txtStatus.setText(data.desc);        
      return row;
  }
  
  static class DataHolder {
      TextView txtPhoneno;
      TextView txtStatus;
  }
  }
  </code></pre>