title: ListView does not show changes until focus changes after notifyDataSetChanged
body: <p>I have an <code>AlertDialog</code> with a <code>ListView</code> set to multiple selection on it. It also has a <code>Button</code> on it.</p>
  
  <p>The <code>Button</code> open another <code>AlertDialog</code> that if ok'ed will remove the selected items from the data set of the <code>ListView</code>, and then tell the adapter of the list view that the dataset has changed with the <code>notifyDataSetChanged()</code> method.</p>
  
  <p>This all works fine except for one thing. The <code>ListView</code> does not update it's content until I interact with something. Then it updates to the correct data.</p>
  
  <p>This is not a big problem, but I really would like the <code>ListView</code> to appear correct at once, and not just after the focus has changed.</p>
  
  <p>Code:</p>
  
  <pre><code>Button remove = (Button) view.findViewById(R.id.btn_remove_questions_edit_rack);
      final Context con = this;
      remove.setOnClickListener(new OnClickListener()
      {
          @Override
          public void onClick(View v)
          {
              Builder warnBuild = new Builder(con);
              warnBuild.setMessage(R.string.question_deletion_warning);
              warnBuild.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
              {
                  @Override
                  public void onClick(DialogInterface dialog, int which)
                  {
                      SparseBooleanArray checked = list.getCheckedItemPositions();
                      for (String s : keys)
                      {
                          int i = keys.indexOf(s);
                          if (checked.get(i))
                          {
                              toRemove.add(map.get(s));
                              map.remove(s);
                          }
                      }
                      keys.clear();
                      keys.addAll(map.keySet());
                      ((ArrayAdapter) list.getAdapter()).notifyDataSetChanged();
                      list.clearChoices(); //This makes sure the selection is cleared, if it isn't, some of the other items (those that now has the index of the selected items) will be selected when the View refreshes.
                      dialog.dismiss();
                  }
              });
  
              //Negative button here, not relevant.
          }
      });
  </code></pre>
  
  <p>Where <code>map</code> and <code>keys</code> are:</p>
  
  <pre><code>final HashMap&lt;String, QualityQuestion&gt; map = new HashMap&lt;&gt;();
  //I add items to the map
  final ArrayList&lt;String&gt; keys = new ArrayList&lt;&gt;(map.keySet());
  </code></pre>
  
  <p>And <code>toRemove</code> is where I store the items to be removed from the actual object they are on when the ok button on the original <code>AlertDialog</code> is pressed.</p>
  
  <p>This is how I populate my <code>ListView</code> in the first place:</p>
  
  <pre><code>final ListView list = (ListView) view.findViewById(R.id.list_questions_edit_rack);
      list.setAdapter(
              new ArrayAdapter&lt;String&gt;(this,
                      android.R.layout.simple_list_item_activated_1,
                      keys));
  </code></pre>
  
  <p>I have tried things like <code>list.invalidateViews()</code>, <code>list.invalidate</code> and other things I found in questions similar to mine here on SO. But none of that made any difference. I suspect my problem to be different from theirs since my items clearly are updated, it just takes a change of focus on the original <code>AlertDialog</code> for the change to be visible.</p>
  
  <p>How can I make the <code>ListView</code> show the changes in it's data source imidiatly insted of after a focus change?</p>