activity获取子fragment的控件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37686625/article/details/80696707

在adapter里面定义currentFragment 

重写 setprimarryItem方法 

使用 adapter.currentFragment .getView().findViewById

public class AdapterViewPager extends FragmentStatePagerAdapter {
 public Fragment currentFragment;
 @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        this.currentFragment = (Fragment) object;
        super.setPrimaryItem(container, position, object);
    }
}
public class ActivityRelationAirport extends ActivityBase {
 (TextView) adapterViewPager.currentFragment.getView().findViewById(R.id.text)).setText("我是当前fragment里面的textview");

}


阅读更多
换一批

没有更多推荐了,返回首页