Activity中获取当前Fragment 中的子控件

时间:2022-06-17 00:25:16

XXXAdapter中 增加

  public Fragment currentFragment;
  @Override
  public void setPrimaryItem(ViewGroup container, int position, Object object) {
   //获取当前fragment
   currentFragment = (Fragment)object;
   super.setPrimaryItem(container, position, object);
  } Activity中保存之前设置的Adapter,获取子viiew
  private XXXAdapter xxxAdapter;
  EditText etName = (EditText)xxxAdapter.currentFragment.getView().findViewById(R.id.et_name);