title: ArrayAdapter.NotifyDataSetChanged() is not working?
body: <p>I have a list that can be updated by the user, but <code>notifyDataSetChanged()</code> is not working on the adapter associated with the <code>listView</code>. I am using it in a fragment. Datbase gets updated, however the adpater doesn't. Following is my implementation:</p>
  
  <p><strong>My Main Fargment:</strong></p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      myArrayList = new ArrayList&lt;myList&gt;();
      myArrayList = Database.getSharedObject(getActivity()).getMyList();
      if (myArrayList != null &amp;&amp; myArrayList.size() &gt; 0) {
          adapter = new myListAdapter(getActivity(), 0, myArrayList);
      }
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      View v = inflater.inflate(R.layout.mainfragment, container, false);
      myListView = (ListView) v.findViewById(R.id.my_list_view);
      myListView.setOnItemClickListener(this);
      if (adapter != null) {
          myListView.setAdapter(adapter);
      }
  
      return v;
  }
  </code></pre>
  
  <p>After some navigations process List gets updated and in my <code>onResume()</code> method I get the updated List from database and call <code>notifyDatasetChanged()</code> method that does not update my view, however corresponding array from DB is updated one.</p>
  
  <pre><code>@Override
  public void onResume() {
      super.onResume();
      myArrayList = Database.getSharedObject(getActivity()).getMyList();
      adapter.setItems (myArrayList);
      adapter.notifyDataSetChanged();
  
  }
  </code></pre>
  
  <p><strong>MyListAdapter</strong></p>
  
  <pre><code>public class MyListAdapter extends ArrayAdapter&lt;Message&gt; {
  
      private ArrayList&lt;Message&gt; myList;
  
      /* Context */
      private Context context;
  
      public void setItems (ArrayList&lt;Message&gt; myList) {
          this.myList = myList;
      }
  
      public MyListAdapter (Context context, int textViewResourceId, ArrayList&lt;Message&gt; myList) {
          super(context, textViewResourceId, myList);
          this.context = context;
          this.myList = myList;
      }
  
      @Override
      public View getView (int position, View v, ViewGroup parent) {
          // Keeps reference to avoid future findViewById()
          MyViewHolder viewHolder;
  
          if (v == null) {
              LayoutInflater li = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              v = li.inflate(R.layout.list_row, parent, false);
  
              viewHolder = new MyViewHolder();
              viewHolder.txtImage = (ImageView) v.findViewById(R.id.message_icon);
              viewHolder.txtMessage = (TextView) v.findViewById(R.id.message);
              viewHolder.txtDate = (TextView) v.findViewById(R.id.date);
  
              v.setTag(viewHolder);
          } else {
              viewHolder = (MyViewHolder) v.getTag();
          }
  
          Message myMessage = new Message();
          myMessage = myList.get(position);
          if (myMessage != null) {
              viewHolder.txtMessage.setText(myMessage.getText());
              viewHolder.txtDate.setText(myMessage.getDate());
          }
          return v;
      }
  
      static class MyViewHolder {
          ImageView txtImage;
          TextView txtMessage;
          TextView txtDate;
      }
  }
  </code></pre>
  
  <p>Any thought on what is going wrong? Why is not listview getting updated? Any helps is appreciated.</p>