1、android 数据传递——实例化对象调用方法

2、(1)在LeftMenuFragment中添加

      public void SetData(String str){

System.out.println("侧栏接收到的数据是"+str);

}

(2)在Main2Activity中根据标查找Fragment

      //根据fragment标签返回Fragment
public LeftMenuFragment getLeftMenuFragment(){
FragmentManager fm = getSupportFragmentManager();
LeftMenuFragment leftMemuFragment = (LeftMenuFragment)                      fm.findFragmentByTag(FRAGMENT_LEFT_MENU);
   return leftMemuFragment;
}

(3)在NewsPager中获取Main2Activity实体,然后获取leftMemuFragment,调用setData()

相关文章:

  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2021-04-20
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-07
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
相关资源
相似解决方案