Calling a method in one fragment from another

前端 未结 5 1513
渐次进展
渐次进展 2020-12-18 00:30

I\'ve been trying for a while already (as well, searching in here) for something to help me to refresh listView in my MainFragment, when a button is pressed in other fragmen

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 01:29

    FragmentManager fm = getFragmentManager(); 
    MainFragment fragm = (MainFragment)fm.findFragmentById(R.id.main_fragment); 
    fragm.otherList(); 
    

    This code worked best for me. And seems quite easy

提交回复
热议问题