title: Using an ArrayAdapter with LiveData.
body: <p>I'm familiar with MVVM in WPF, but am in the process of porting an existing Android app to make use of a ViewModel class and LiveData for the first time. </p>
  
  <p>The app "as/was" has a custom ArrayAdapter that is used to correctly display the items contained in a List in a gridview. The code that does that looks essentially like this ("essentially" because there are actually 4 such grids in the activity that all do it like this):</p>
  
  <pre><code>ArrayAdapter&lt;String&gt; playerAdapter = new MyAdapter&lt;String&gt;(this, R.layout.grid_item, playerList);
  
  gridView.setAdapter(playerAdapter)
  </code></pre>
  
  <p>and when the playerList contents changed, there was an explicit call to </p>
  
  <pre><code>playerAdapter.notifyDataSetChanged()
  </code></pre>
  
  <p>Since my goal is to have the grid respond automatically when the playerList changes, and never have to notify anything, it seems now that the "playerList" needs to become a <code>MutableLiveData&lt;List&lt;String&gt;&gt;</code>.</p>
  
  <p>I suspect I am going to have a problem though-</p>
  
  <p>The MyAdapter class extends <code>ArrayAdapter&lt;T&gt;</code></p>
  
  <p>So in practice it's going to become an </p>
  
  <pre><code>ArrayAdapter&lt;MutableLiveData&lt;List&lt;String&gt;&gt;&gt;
  </code></pre>
  
  <p>But a MutableLiveData isn't going to work there, right?</p>
  
  <p>I could unwrap it and make the call to create it look like this:</p>
  
  <blockquote>
  <pre><code>ArrayAdapter&lt;String&gt; playerAdapter = 
  new MyAdapter&lt;String&gt;(this, R.layout.grid_item, playerList.getValue());
  </code></pre>
  </blockquote>
  
  <p>Is this correct? It seems the way of madness.</p>
  
  <p>Ultimately my goal is to just assign the gridView's <code>android:adapter</code> property to this thing in xml and never have to think about it anymore (beyond the required calls to setvalue() and postValue() when I modify the underlying list...which I'm not even sure how would work here.</p>
  
  <p>I would hope there's already a MutableLiveData Collection that's ready to go somewhere and I'd use that.</p>
  
  <p>What the standard way to do this?</p>