Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are likely going to have write your own <code>Filter</code> and attach it via a <code>TextWatcher</code>. This response has an example of regex in an <code>AutoCompleteTextView</code>: <a href="https://stackoverflow.com/questions/5691356/android-autocompletetextview-with-regular-expression">Android AutoCompleteTextView with Regular Expression?</a> and here is another regex/java example: <a href="https://stackoverflow.com/questions/2469231/how-can-i-perform-a-partial-match-with-java-util-regex">How can I perform a partial match with java.util.regex.*?</a></p> <p>EDIT: You will need to extend ArrayAdapter in order to override getFilter() and return your custom filter.</p> <p>So you are going to have something like this:</p> <pre><code>autoCompleteTextView.setAdapter(arrayAdapter); autoCompleteTextView.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { arrayAdapter.getFilter().filter(s); } }); public class RegexFilter extends Filter{ ArrayAdapter&lt;String&gt; mAdapter; public RegexFilter(ArrayAdapter&lt;String&gt; adapter) { mAdapter = adapter; } ... @Override protected FilterResults performFiltering(CharSequence constraint) { Pattern p = Pattern.compile(constraint); Matcher m = p.matcher(""); List listOfMatches = new ArrayList&lt;String&gt;(); for (String curMonth : months) { m.reset(curMonth); if (m.matches || m.hitEnd()) { listOfMatches.add(curMonth); } } FilterResults results = new FilterResults(); results.values = listOfMatches; results.count = listOfMatches.size(); return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { mAdapter.addAll(results.values); mAdapter.notifyDataSetChanged(); } } public class PartialArrayAdapter extends ArrayAdapter&lt;String&gt; { ... RegexFilter mFilter; @Override public TimedSuggestionFilter getFilter() { if(null == mFilter) mFilter = new RegexFilter(this); return mFilter; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload