title: How to customize the "chips" auto-suggesting mechanism, as used on Gmail's recipients field?
body: <h2>Background</h2>
  
  <p>I've searched for a way to have a similar look &amp; feel to the Gmail receipients field, which allows auto-filling of items in a really cool way:</p>
  
  <p><img src="https://i.stack.imgur.com/Y0CkV.png" alt="enter image description here"></p>
  
  <p>The class that is built into the Android framework and is responsible for this is called "<a href="http://developer.android.com/reference/android/widget/MultiAutoCompleteTextView.html" rel="nofollow noreferrer"><strong>MultiAutoCompleteTextView</strong></a>" .</p>
  
  <h2>The problem</h2>
  
  <p>the MultiAutoCompleteTextView is quite basic, yet it doesn't hold enough samples, tutorials and libraries to get to know how to customize it like on Gmail and the likes.</p>
  
  <p>I would like to know how to customize it to handle any kind of data, and that I will have full control over it (for example adding, deleting and getting the items that it has auto-completed).</p>
  
  <h2>What I've tried</h2>
  
  <p>I've found the next possible ways to achieve it:</p>
  
  <ol>
  <li>use a third library like <a href="https://github.com/splitwise/TokenAutoComplete" rel="nofollow noreferrer"><strong>splitwise-TokenAutoComplete</strong></a>. the downside: it's very buggy and doesn't work well on some devices.</li>
  <li>create my own way (as shown <a href="https://stackoverflow.com/questions/19676347/setting-multiple-custom-elements-to-multiautocompletetextview-android/"><strong>here</strong></a>). the downside: will take a long time and I will probably need to handle the same problems as of the library.</li>
  <li>use the <a href="https://android.googlesource.com/platform/frameworks/ex/+/android-sdk-support_r11" rel="nofollow noreferrer"><strong>code of Google</strong></a> (found <a href="https://plus.google.com/+RichHyndman/posts/TSxaARVsRjF" rel="nofollow noreferrer"><strong>here</strong></a>). The downside: it's really not customizable.</li>
  </ol>
  
  <p>I've decided to use #3 (Google's chips library).</p>
  
  <p>Currently the code for getting the list of contacts used on Google's library:</p>
  
  <pre><code>public List&lt;RecipientEntry&gt; doQuery() {
      final Cursor cursor = mContentResolver.query(mQuery.getContentUri(), mQuery.getProjection(), null, null, null);
      final LinkedHashMap&lt;Long, List&lt;RecipientEntry&gt;&gt; entryMap = new LinkedHashMap&lt;Long, List&lt;RecipientEntry&gt;&gt;();
      final List&lt;RecipientEntry&gt; nonAggregatedEntries = new ArrayList&lt;RecipientEntry&gt;();
      final Set&lt;String&gt; existingDestinations = new HashSet&lt;String&gt;();
      while (cursor.moveToNext())
          putOneEntry(new TemporaryEntry(cursor, false /* isGalContact */), true, entryMap, nonAggregatedEntries,
                  existingDestinations);
      cursor.close();
      final List&lt;RecipientEntry&gt; entries = new ArrayList&lt;RecipientEntry&gt;();
      {
          for (final Map.Entry&lt;Long, List&lt;RecipientEntry&gt;&gt; mapEntry : entryMap.entrySet()) {
              final List&lt;RecipientEntry&gt; entryList = mapEntry.getValue();
              for (final RecipientEntry recipientEntry : entryList)
                  entries.add(recipientEntry);
          }
          for (final RecipientEntry entry : nonAggregatedEntries)
              entries.add(entry);
      }
      return entries;
  }
  </code></pre>
  
  <p>It works fine, but I'm having difficulties adding items and deleting them.</p>
  
  <p>I think that getting the items is used by calling "getContactIds" , but about modifying the items within the chips, that's very problematic to find.</p>
  
  <p>For example, I've tried to add a similar function to "submitItemAtPosition" , which seems to add a new entity found from the adapter. It does add, but the display-name of the contact isn't shown on the chip itself.</p>
  
  <h2>The question</h2>
  
  <p>After a lot of thoughts, I decided to use Google's code.</p>
  
  <p>Sadly, as I've written, the view and its classes are very tight to the usage of it.</p>
  
  <ol>
  <li><p>How can I de-couple the view and make it much more customizable? How can I make it use any type of data instead of just what Google has done?</p></li>
  <li><p>How do I get which items were entered (that became "chips"), and also be able to remove or add items from outside?</p></li>
  </ol>