Friday, 15 May 2015

android - SearchView not firing onQueryTextChange method to filter ListView -


For some reason, my search will not be exactly the filter on my list - it will not enter into onQueryTextChange method. Here is my code

  public static class PokemonMoveTutorFragment extends implements SearchView.OnQueryTextListener {private static final String ARG_SECTION_NUMBER = "SECTION_NUMBER" piece; Public static PokemonMoveTutorFragment newInstance (int sectionNumber) {PokemonMoveTutorFragment piece = new PokemonMoveTutorFragment (); Bundle args = new bundle (); Args.putInt (ARG_SECTION_NUMBER, section number); Fragment.setArguments (args); Return piece; } Public PokemonMoveTutorFragment () {} @Override public view onCreateView (LayoutInflater inflater, ViewGroup container, bundle savedInstanceState) {See rootView = inflater.inflate (R.layout.fragment_poke_details_tabs_moves, container, false); SearchView searchView = (SearchView) rootView.findViewById (R.id.searchViewMoves); ListView l1 = (ListView) rootView.findViewById (R.id.pokeMoveList); TextView header = (TextView) rootView.findViewById (R.id.moveListHeader); Header.setText ("Move: Tutor"); ArrayList & LT; Move & gt; Tricks = poke. Forgiveness (); ArrayList & LT; Move & gt; ShowMovesList = New Arrestists & lt; & Gt; (); (Move move: moved list) {if (move.getLearnMethod () == 3) {showMovesList.add (move); }} Collections.sort compareTo (showMovesList, new Comparator () {public int compare (Object O1, O2 object) move {p1 = (move) O1; Move p2 = (move) o2 ;. return PlkgetMoveName () (P2 .getMoveName ());}}); MoveListAdapter = New MoveListAdapter (con, showMovesList, false); L1.setAdapter (moveListAdapter); SearchView.setOnQueryTextListener (this); Return root view; } @ Override Public Boolean onQueryTextChange (string newtext) {Log.i ("SEARCHTEST", "OnQueryTextChange: MoveList:" + newText); . MoveListAdapter.getFilter () filter (newText); return false; } @ Override public boolean onQueryTextSubmit (string query) {return false; }}  

There are many uses of the same layout file for different pieces, none of which does not work

In another activity, I also have a list view (Where the layout file is also used for many pieces) that works perfectly - but for some reason, although both implementations are equally identical, this will not work for me.

Any ideas why? Thanks in advance

If you want, I can post the layout file code as well as the adapter code, but since I can not even get it, I can not understand that the problem is there

EDIT: Of course, immediately after posting I know something. In some way, it works in some pieces, but not others, although it will work in other people, if already entered in the text which works normally and it generally works oncutTextChange The method will be recorded.

So this is very confusing, I think it is related to many pieces reaching the same layout file - any ideas for how to fix it?

Well I fixed it, it was really a stupid mistake on my part: D

I used the same adapter for ListView in each section, which was causing the problem. A simple change to make adapters local for every piece fixed the issue.


No comments:

Post a Comment