java - Custom listview search works successfully but doesnt show new results on pressing backspace in the edittext -
I am using a custom adapter for a list. There is a search bar in it.
Code:
txtsearcher.addTextChangedListener (New TextWater () {@Override is testwired on public Zero (parameter, s, int int, int count) {StoreDetails .this.cdadp.getFilter () filter (s.toString ());} @ Override public lesson before text (varies), intersection, int start, int count, int after) {// TODO automatically generated method Stub} @TextChanged @ edited override public zero too auto-generated mass stub}}); Adapter class:
public custom details adapter (activity reference, arreist & lt; store_data> store_list, double current_litidity, double current_line) {this .context = context; Details_inflate = LayoutInflater.from (reference); This.store_list = store_list; This.current_latitude = current_latitude; This.current_longitude = current_longitude; Temp_list = store_list; } Public Category filter_ here {// ArrayList & lt; String & gt; Name = New Array's & lt; String & gt; (); // ArrayList & LT; Store_data & gt; Store_list; @ Override Protected Filter: Refillful Filtering (squared off) {// Tudo Auto-Generated Method Stub // store_list = New Arrestist & lt; Store_data & gt; (); // for (int i = 0; i & lt; store_list.size (); i ++) // {// store_names.add (store_list.get (i) .store_name); //} Filter result result = new filter result (); // If the barrier is empty, then return the original name (constrain.length () == 0) {Result.values = temp_list; Result.count = temp_list.size (); } And if (bound. Length ()> gt; {ArrayList & lt; Store_data & gt; Filtered_name = new Array's & lt; Store_data & gt; (); String filter string = barrier Tracing (). ToLowerCase (); (Store_data's: store_list) {string filterable string = s.store_name.toLowerCase (). ToString (); If (filtered stringcontent (filter string)) {filtered_Names.add (s); }} Result.values = filtered_Names; Result.count = filtered_Names.size (); } Return results; } @ Override Protected Zero Publish Replied (Chausensense Barrier, Filter Result Results) {/ TODO Automatically Generate Method Stub If (Results.count == 0) Notify DataSet Valid (); Else {store_list = (ArrayList & lt; store_data & gt;) results.values; NotifyDataSetChanged (); Search} works fine But when I type "SP", all values with SP are displayed. When I press the space bar after that entry with "SP" and other words. But when I press the backspace on the keypad and make the string in the form "S", then all values of S are not shown. How do I register backed events. I tried the following, but this work:
txtsearcher.setOnKeyListener (New Oneness Listener) {@Override Public Boolean ON (see V, Int kikod, Key Event Event) {if (keycode == KeyEvent.KEYCODE_BACK) {string s = Txtsearcher.getText () .toString (); StoreDetails.this.cdadp.getFilter () .filter (s.toString ());} return false;} });
You are listening to the back key (keycode == KeyEvent.KEYCODE_BACK) but you Say "backspace in text edit" Do you mean the key to delete on the keyboard? In this case, try KeyEvent.KEYCODE_DEL
Comments
Post a Comment