title: How to apply search filter using startsWith on a simple listview in android
body: <p>I have a <code>ListView</code> that gets data from a database. I applied the <strong>search filter</strong> on it, but it doesn't filter as I want. what I want is to filter with the <strong>first letter</strong> not middle or contains.</p>
  <p>Here is the code:</p>
  <pre><code>public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
  
      ListView dicList; 
      EditText editSearch;
      ArrayAdapter&lt;String&gt; adapterListOfWord;
      ArrayList&lt;String&gt; mSource = new ArrayList&lt;String&gt;();
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          editSearch = findViewById(R.id.edit_search);
          dicList = findViewById(R.id.dic_list);
  
          adapterListOfWord = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, mSource);
          dicList.setAdapter(adapterListOfWord);
  
          editSearch.addTextChangedListener(new TextWatcher() {
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
              }
  
              @Override
              public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
                  // the problem is here, i want to search with the first letter not middle or contains.
                  adapterListOfWord.getFilter().filter(charSequence);
              }
  
              @Override
              public void afterTextChanged(Editable s) {
  
              }
          });
      }
  }
  </code></pre>
  <p>I don't know how to implement and apply filterable to my project according to my codes and change the <code>contains()</code> to <code>startsWith()</code> to reach my goal.<br />
  I really appreciate your help.<br />
  Thanks in advance.</p>