Here is an android programming question. I follow the offical example and write an activity that consist of two fragments which show a list menu and content. When user click a item in list, detail will be shown in content fragment. Now, I want to add a refresh button in Actionbar. When user click it, content in content fragment will be reloaded.
But I don't know how to get the reference of the running content fragment and call it to refresh. (Suppose all content fragments have already implemented a method called refresh())
public class FragmentLayout extends Activity { ..... public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_reload: //refresh button is clicked //how can I call the DetailFragment to reload here? } public static class TitlesFragment extends ListFragment { .... } public static class DetailFragment extends Fragment { ... } In short, how the fragment and the activity contains the fragment to communicate?