简体   繁体   English

从Activity重新加载recyclerview

[英]Reload recyclerview on fragment from Activity

I have an fragment with an recyclerView , I need to search in a SearchView ubicated in a fragment. 我有一个带有recyclerViewfragment ,我需要在片段中的SearchView进行搜索。 I implemented in my activity this: 我在活动中实现了以下目的:

Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
  String query = intent.getStringExtra(SearchManager.QUERY);
  doMySearch(query);
}

I don't know how I refresh the recyclerview on fragment where is the SearchView . 我不知道如何在SearchView所在的片段上刷新recyclerview

Probably a few different ways to do this but you should be able to call method on your fragment from the activity (either using some reference to fragment you have already or perhaps looking it up like following) 可能有几种不同的方法可以执行此操作,但是您应该能够从活动中对片段进行调用(使用某些引用来引用已经存在的片段,或者像下面那样查找它)

    MyFragment myFragment = (MyFragment) getFragmentManager().findFragmentById(R.id.my_fragment);
    myFragment.updateResults();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM