Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>NOTE: The purpose of baseAdapters is to set data on your listview. So the checking must be done on the class where the EditText has been declared.</p> <p>By utilizing the TextWatcher interface which checks the updated value of your EditText,</p> <pre><code>public class SearchActivity extends Activity implements TextWatcher{ private EditText searchField; private SearchActivity activity; private ListView listView; private String [] matches; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.yourLayout); activity = this; searchField = (EditText)findViewById(R.id.searchField); searchField.addTextChangedListener(this); listView = (ListView)findViewById(R.id.list); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { //your action } }); } @Override public void afterTextChanged(final Editable searchField) { listView.setAdapter(null); //check for matches here and store it to newly created array of Strings if(searchField.length()&gt;0 &amp;&amp; matches.length &gt; 0){ //added another condition here listView.setAdapter(new YourAdapter()); }else{ this.searchField.setTextColor(Color.RED); // &lt;--changes HERE } } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {} } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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