title: callback to notifyDataSetChanged
body: <p>I implemented a listview inside DialogFragment. Each item has a textview with a selector to simulate a radio group with option to select only one item at a time.
  The problem is when the user clicks on an item I am updating the data on the adapter then calling to <code>notifyDataSetChanged()</code> and calling <code>dialog.dismiss()</code>.
  The user don`t see the selection of item before the dialog is dismissed.
  I fixed this by adding postdelay to dismiss functionality, Maybe there is a better solution for this problem?</p>
  
  <p>This is my code:</p>
  
  <pre><code>public class SettingsPopupAdapter extends BaseAdapter
  {
      private List&lt;SettingsItem&gt;  _data;
      private Context             _con;
      public SettingsPopupAdapter(Context con, List&lt;SettingsItem&gt; data)
      {
          _con = con;
          _data = data;
      }
  
      @Override
      public int getCount()
      {
          return _data.size();
      }
  
      @Override
      public SettingsItem getItem(int position)
      {
          return _data.get(position);
      }
  
      @Override
      public long getItemId(int position)
      {
          return 0;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent)
      {
          ViewHolder holder;
          if (convertView == null)
          {
              holder = new ViewHolder();
              convertView = LayoutInflater.from(_con).inflate(R.layout.settings_popup_checkbox_row_item, parent, false);
              holder._text = (TextView) convertView.findViewById(R.id.option_text);
              convertView.setTag(holder);
          }
          else
          {
              holder = (ViewHolder) convertView.getTag();
          }
  
          SettingsItem item = getItem(position);
          holder._text.setText(item.getItemLabel());
          holder._text.setSelected(item.isSelected());
  
  
          return convertView;
      }
  
      private static class ViewHolder
      {
          public TextView     _text;
      }
  
      public String getSelectedItem()
      {
          String selectedItem = null;
          for (SettingsItem item : _data)
          {
              if (item.isSelected())
              {
                  selectedItem = item.getItemLabel();
                  break;
              }
          }
          return selectedItem;
      }
  
      public List&lt;String&gt; getSelectedItems()
      {
          List&lt;String&gt; selectedOptions = new ArrayList&lt;String&gt;();
  
          for (SettingsItem item : _data)
          {
              if (item.isSelected())
              {
                  selectedOptions.add(item.getItemLabel());
              }
          }
  
          return selectedOptions;
      }
  
      public void setData(ArrayList&lt;SettingsItem&gt; items)
      {
          _data = items;
          notifyDataSetChanged();
      }
  }
  </code></pre>
  
  <p>This code is in the fragment from where I am opening the dialog :</p>
  
  <pre><code>private SettingsPopupAdapte _modAdapter;
  private ArrayList&lt;SettingsItem&gt; _items;
  _modAdapter = new SettingsPopupAdapter(getActivity(),_items);
  _modificationListView.setAdapter(_modAdapter);
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id)
  {   
      String selectedItem =  _items.get(position).getItemLabel();
      selectExclusiveList(selectedItem);
  
      Bundle b = new Bundle();
      b.putInt(Consts.MODIFICATION_TYPE_KEY, _type);
      b.putString(Consts.RESPONSE_DATA_KEY,selectedItem);
      _listener.onRetrieveData(b);
  
      //show the change before the dialog dismissed 
      getView().postDelayed(new Runnable()
      {
          @Override
          public void run()
          {
              dismiss();
          }
      },200);
  }
  
  private void selectExclusiveList(String selectedItem)
  {
      for (SettingsItem item : _items)
      {
          item.setSelected(false);
          if (item.getItemLabel().equals(selectedItem))
          {
              item.setSelected(true);
          }
      }
      _modAdapter.setData(_items);
  }
  </code></pre>