Android SearchView未启动onQueryTextChange方法以筛选ListView

Android SearchView未启动onQueryTextChange方法以筛选ListView,android,Android,出于某种原因,我的搜索视图根本不会过滤我的列表——它甚至不会输入onQueryTextChange方法。这是我的密码 public static class PokemonMoveTutorFragment extends Fragment implements SearchView.OnQueryTextListener { private static final String ARG_SECTION_NUMBER = "section_number"; publ

出于某种原因,我的搜索视图根本不会过滤我的列表——它甚至不会输入onQueryTextChange方法。这是我的密码

    public static class PokemonMoveTutorFragment extends Fragment implements SearchView.OnQueryTextListener {

    private static final String ARG_SECTION_NUMBER = "section_number";

    public static PokemonMoveTutorFragment newInstance(int sectionNumber) {
        PokemonMoveTutorFragment fragment = new PokemonMoveTutorFragment();
        Bundle args = new Bundle();
        args.putInt(ARG_SECTION_NUMBER, sectionNumber);
        fragment.setArguments(args);
        return fragment;
    }

    public PokemonMoveTutorFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View 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("MOVES: TUTOR");
        ArrayList<Move> movesList = poke.getMoveset();
        ArrayList<Move> showMovesList = new ArrayList<>();
        for (Move move : movesList) {
            if (move.getLearnMethod() == 3) {
                showMovesList.add(move);
            }
        }

        Collections.sort(showMovesList, new Comparator() {
            public int compare(Object o1, Object o2) {
                Move p1 = (Move) o1;
                Move p2 = (Move) o2;
                return p1.getMoveName().compareTo(p2.getMoveName());
            }
        });

        moveListAdapter = new MoveListAdapter(con,showMovesList,false);
        l1.setAdapter(moveListAdapter);
        searchView.setOnQueryTextListener(this);
        return rootView;
    }

    @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;
    }
}
同一布局文件对不同片段有多种用途,但都不起作用

在另一个活动中,我还搜索一个列表视图,其中布局文件也用于多个功能完美的片段——但由于某种原因,即使两个实现实际上完全相同,这对我来说也不起作用

知道为什么吗?提前谢谢

如果您愿意,我可以发布布局文件代码和适配器代码,但是因为我甚至不能让onQueryTextChange启动,所以我认为问题不在这里

日志中没有任何错误或任何东西表明发生这种情况的原因

编辑:当然,发布后我马上发现了一些东西。 不知何故,它在某些片段中起作用,但在其他片段中不起作用,尽管如果在正常工作的片段中已经输入了文本,它在其他片段中也会起作用。对于正常工作的方法,它将输入onQueryTextChange方法


所以这很让人困惑,我假设这与访问同一布局文件的多个片段有关-有没有解决这个问题的方法?

好吧,我已经解决了,我犯了一个愚蠢的错误:D

我在每个片段中对ListView使用了相同的适配器,这导致了问题。一个简单的更改使适配器对每个片段都是本地的,修复了这个问题