使fragment:The specified child already has a parent. You must call removeView() on the child's parent

FragmentActivity+Fragment

在Fragment生命周期方法

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.preference_fragment, container);
        return v;
    }

改为:

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.preference_fragment, container, fasle);
        return v;
    }

你可能感兴趣的:(Android)