Fragment中获取Activity的方法进行fragment的切换

    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></FrameLayout>
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.frame, TUIConversationFragment.newInstance(0)).commit();
    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    
    
        super.onViewCreated(view, savedInstanceState);
        com.tencent.qcloud.tuikit.tuiconversation.Constant.position = 0;
        TUIConstant.isGroup = false;
//        Fragment中获取Activity的方法进行fragment的切换
        getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.frame, TUIConversationFragment.newInstance(0)).commit();
        initView(view);
    }

猜你喜欢

转载自blog.csdn.net/xiyangyang8110/article/details/126366520