切换片段后无法在视图中填充数据

Unable to populate data in Views after switching fragments

同上 - 我无法在切换片段时将数据填充到视图(例如 ImageView、TextView)中。

onCreateView - 我执行 AsyncTask 向服务器发送请求。 我使用接口来了解 AsyncTask 何时结束其工作。 完成后,我将数据填充到视图中。 它工作得很好,但当我切换片段时却没有。

我知道检索数据没有问题,唯一的问题是将其填充到视图中。

由于您在这里没有代码,所以我给您提供了一个来自我的应用程序的工作示例,该应用程序起诉了片段:-

public class FragmentA extends Fragment {
    private View mRoot;
    ....
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mRoot = inflater.inflate(R.layout.fragment_layout, container, false);
        updateUI();
        return mRoot;
    }

    private void updateUI() {
       TextView1 = (TextView) mRoot.findViewById(R.id.id1);
       TextView2 = (TextView) mRoot.findViewById(R.id.id2);
       ....
       ....
    }
}

更新

既然我看到了您的代码,请尝试通过 rootView

更改各个视图
final ConstraintLayout treeline_Tier = (ConstraintLayout) treelineView.findViewById(R.id.treeline);

treelineView --> rootView