title: why notifyDataSetChanged() isn't updating my list
body: <p>I have working with custom list view many times but I haven't faced this problem.. I see lot questions of same type and tried their solutions but my listview isn't updating when I call notifyDatasetChanged() method.</p>
  
  <p>here is my code
  in <code>onCreate()</code></p>
  
  <pre><code>adapter=new AppointmentAdapter(context, R.layout.appointments_layout,list );
  appointments.setAdapter(adapter);
  </code></pre>
  
  <p>and this is where I have called notifyDatasetChanged.</p>
  
  <pre><code>JsonDataCallback callbackservice = new JsonDataCallback(Appointments.this, obj) {
                  @Override
                  public void receiveData(Object object) {
                      try {
                          adapter.clear();
                          list=new ArrayList&lt;AppontmentBean&gt;();
                          String userappointments = (String) object;
                          if(userappointments!=null &amp;&amp; userappointments.trim().length()&gt;10)
                          {
                          JSONObject appointmentsjson = new JSONObject(userappointments);
  
                          JSONArray appoinmentsArray=appointmentsjson.getJSONArray("EMRTable");
                          for(int i=0;i&lt;appoinmentsArray.length();i++)
                          {
                              JSONObject appointment1=appoinmentsArray.getJSONObject(i);
                              String name=appointment1.getString("PersonLastNameFirstName");
                              String time=appointment1.getString("StartTime").split("T")[1];
  
                              String strDateFormat = "HH:mm a";
                              String strDateFormat1 = "HH:mm:ss";
                               SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat1);
                               SimpleDateFormat sdf1 = new SimpleDateFormat(strDateFormat);
                              Date d=sdf.parse(time);
                              time=sdf1.format(d);
  
                              String reason=appointment1.getString("ReasonForVisit");
                              list.add(new AppontmentBean(name, time, reason));
                          }
                          }
                          else{
                              Toast.makeText(context, "No Appointments", Toast.LENGTH_SHORT).show();
                          }
                          adapter.notifyDataSetChanged();
  </code></pre>
  
  <p>I have debugged values are added to the list but the list adapter doesn't updating.</p>
  
  <p>But when I use like this my list is updating</p>
  
  <pre><code>adapter=new AppointmentAdapter(context, R.layout.appointments_layout,list );
                      appointments.setAdapter(adapter);
  </code></pre>
  
  <p>is it a good practice to use this.</p>
  
  <p>Edit:
  Adapter class</p>
  
  <pre><code>public class AppointmentAdapter extends ArrayAdapter&lt;AppontmentBean&gt; {
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return countryList.size();
      }
  
  Context context;
      private ArrayList&lt;AppontmentBean&gt; countryList;
  
      public AppointmentAdapter(Context context, int textViewResourceId, ArrayList&lt;AppontmentBean&gt; countryList) {
          super(context, textViewResourceId, countryList);
          this.countryList = new ArrayList&lt;AppontmentBean&gt;();
          this.countryList.addAll(countryList);
          this.context=context;
      }
  
  
      private class ViewHolder {
          TextView time;
          TextView name;
          TextView reason;
      }
  @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  
  /***
   * customizing the view by overriding getview
   */
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
  
          ViewHolder holder = null;
  
          if (convertView == null) {
              LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = vi.inflate(R.layout.appointments_layout, null);
  
              holder = new ViewHolder();
              holder.name=(TextView)convertView.findViewById(R.id.patientName);
              holder.time = (TextView) convertView.findViewById(R.id.time);
              holder.reason = (TextView) convertView.findViewById(R.id.visitreason);
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
  
          AppontmentBean appintments = countryList.get(position);
  
          holder.name.setTypeface(null, Typeface.BOLD);
          holder.name.setTag(appintments);
          holder.name.setText(appintments.getName());
          holder.name.setContentDescription(appintments.getId());
          if(appintments.getReason()!=null &amp;&amp; appintments.getReason().length()!=0)
          {
              holder.reason.setText(appintments.getReason());
          }
          else
          {
              holder.reason.setVisibility(TextView.GONE);
          }
          holder.time.setText(appintments.getNumber());
          convertView.setContentDescription(appintments.getId());
  
          return convertView;
      }
  }
  
  class AppontmentBean{
  
      AppontmentBean(String Id,String name,String number,String reason)
      {
          this.Id=Id;
          this.name=name;
          this.reason=reason;
          this.number=number;
      }
      String name,number,reason,Id;
  
      /**
       * @return the id
       */
      public String getId() {
          return Id;
      }
  
      /**
       * @param id the id to set
       */
      public void setId(String id) {
          Id = id;
      }
  
      /**
       * @return the name
       */
      public String getName() {
          return name;
      }
  
      /**
       * @param name the name to set
       */
      public void setName(String name) {
          this.name = name;
      }
  
      /**
       * @return the number
       */
      public String getNumber() {
          return number;
      }
  
      /**
       * @param number the number to set
       */
      public void setNumber(String number) {
          this.number = number;
      }
  
      /**
       * @return the reason
       */
      public String getReason() {
          return reason;
      }
  
      /**
       * @param reason the reason to set
       */
      public void setReason(String reason) {
          this.reason = reason;
      }
  
  }
  </code></pre>