在片段中未调用AfterViews方法?

3

我在Fragment类中使用Android Annotation,但是标注了@AfterViews的方法没有被调用。这是代码:

@EFragment(R.layout.fragment_onboarding_base)
public class AddEntityFragment extends Fragment {

@ViewById ViewPager onBoardingViewPager;

public static AddEntityFragment newInstance() {
    AddEntityFragment addEntityFragment = new AddEntityFragment();
    return addEntityFragment;
}

@AfterViews
void afterViewCreated(){
    onBoardingViewPager.setAdapter(new CustomOnBoardingPagerAdapter(getChildFragmentManager(), getContext()));
}
}

我在这里做错了什么?我检查了我的调试点,它没有进入afterViewCreated()方法。任何帮助都将不胜感激。


为什么不使用 onViewCreated - L. Swifter
1个回答

3
问题在于您没有使用生成的类。您应该改用以下方法:
AddEntityFragment fragment = AddEntityFragment_.builder().build();
// add the fragment in a transaction

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接