当单击片段内的按钮时,我想转到父 TabLayout 中的另一个片段

When click button inside fragment I want to go to another fragment in the parent TabLayout

我有一个 MainActivity,包含具有两个片段 FA、FB 的 TabLayout

具有另一个 Tablayout 的第一个片段 FA 包含 2 个片段 FAA、FAB

我在 FAA 中有一个按钮,我希望当我点击它时,它会将我发送到已经在父 TabLayout 中的 FB

我尝试了很多解决方案但没有帮助,有什么建议吗?

    @OnClick(R.id.frag_timeline_fab_faa)
public void goToFBFromFAA(View view) {

    // Code shoud be here
}

方法是通过接口。Here is a similar question I found

在 FAA 片段中:

public interface OnFragmentInteractionListener {
    void onFragmentInteraction(Param param);
}

然后在您的父片段中您需要实现该接口:

public class FA extends Fragment implements 
        FAA.OnFragmentInteractionListener {
    @Override
    public void onFragmentInteraction(Param param) {
    //Your code here
    }
}