Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Textwatcher code </p> <pre><code>inputSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text mainmenu2.this.adapter1.getFilter().filter( cs); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } }); </code></pre> <p>and inside</p> <pre><code>public class SimpleSectionAdapter&lt;T&gt; extends BaseAdapter { </code></pre> <p>implements Filterable like this</p> <pre><code>public class SimpleSectionAdapter&lt;T&gt; extends BaseAdapter implements Filterable </code></pre> <p>and then use this android.widget.Filter getFilter() inside SimpleSectionAdapter ("edit it according to ur's, its just an example) </p> <pre><code>public android.widget.Filter getFilter() { // TODO Auto-generated method stub return new android.widget.Filter() { @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint, FilterResults results) { // TODO Auto-generated method stub mDisplayedValues = (ArrayList&lt;Product&gt;) results.values; // has the filtered values notifyDataSetChanged(); // notifies the data with new filtered values } @Override protected FilterResults performFiltering(CharSequence constraint) { // TODO Auto-generated method stub FilterResults results = new FilterResults(); // Holds the results of a filtering operation in values ArrayList&lt;Product&gt; FilteredArrList = new ArrayList&lt;Product&gt;(); if (mOriginalValues == null) { mOriginalValues = new ArrayList&lt;Product&gt;(mDisplayedValues); // saves the original data in mOriginalValues } /******** * * If constraint(CharSequence that is received) is null returns the mOriginalValues(Original) values * else does the Filtering and returns FilteredArrList(Filtered) * ********/ if (constraint == null || constraint.length() == 0) { // set the Original result to return results.count = mOriginalValues.size(); results.values = mOriginalValues; } else { constraint = constraint.toString().toLowerCase(); for (int i = 0; i &lt; mOriginalValues.size(); i++) { String data = String.valueOf(mOriginalValues.get(i).fname); if (data.toLowerCase().startsWith(constraint.toString())) { FilteredArrList.add(new Product(mOriginalValues.get(i).id,mOriginalValues.get(i).fname,mOriginalValues.get(i).lname)); } } // set the Filtered result to return results.count = FilteredArrList.size(); results.values = FilteredArrList; } return results; } }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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