Android-具有多个片段的选项卡布局,排序不起作用

我正在使用Tablayout和Viewpager进行活动,对于每个选项卡,我都有一个单独的片段类和包含listview的xml。我在活动中使用微调器,以按名称和编号对listview中的项目进行排序。我已经访问了每个片段中的spinner变量,并尝试根据spinner选择重新加载listview。但是它不能与所有选项卡一起使用,只有一个选项卡可以使用,当我单击其他选项卡并返回上一个选项卡时,也不能使用。请查看我的代码,并弄清哪里出了问题。

HWDetailsViewPagerAdapter

 public class HWDetailsViewPagerAdapter extends FragmentPagerAdapter {

    private Context context;
    int totalTabs;

    public HWDetailsViewPagerAdapter(Context context, FragmentManager fm, int totalTabs) {
        super(fm);
        this.context = context;
        this.totalTabs = totalTabs;
    }

    @Override
    public Fragment getItem(int position) {

        switch (position){
            case 0:
                configureSort(mStudentsNotReceivedList);
                return new NotReceivedFragment(mStudentsNotReceivedList, sourceActivity);
            case 1:
                configureSort(mStudentsUncompletedList);
                return new UnCompletedFragment(mStudentsUncompletedList, sourceActivity);
            case 2:
                configureSort(mStudentsCompletedList);
                return new CompletedFragment(mStudentsCompletedList,sourceActivity);
            case 3:
                configureSort(mStudentsList);
                return new AllFragment(mStudentsList, sourceActivity);

        }
        return null;
    }

    @Override
    public int getCount() {
        return totalTabs;
    }
}

UnCompletedFragment.java

public class UnCompletedFragment extends Fragment {
       String sourceActivity;

public UnCompletedFragment(ArrayList<StudentHomeworkProcess> unCompletedLSt,     String sourceActivity) {
    this.unCompletedLSt = unCompletedLSt;
    this.sourceActivity = sourceActivity;
}

StudentsHomeworkProcessAdapter mStudentsHomeworkProcessAdapter;

ArrayList<StudentHomeworkProcess> unCompletedLSt = new ArrayList<>();
ListView unCompletedLstView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.efw_fragment_uncompleted, container, false);
    unCompletedLstView = view.findViewById(R.id.ubcompletedLstViewid);
    mStudentsHomeworkProcessAdapter = new
            StudentsHomeworkProcessAdapter(getActivity(), unCompletedLSt, sourceActivity);
    unCompletedLstView.setAdapter(mStudentsHomeworkProcessAdapter);


    ((PreviousHomeworkDetailsActivity) getActivity()).sortSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            String selectedItem = ((PreviousHomeworkDetailsActivity) getActivity()).sortTypes[i];


            if (selectedItem.equals("الإسم")) {
                Collections.sort(unCompletedLSt, new Comparator<StudentHomeworkProcess>() {
                    /* This comparator will sort objects alphabetically. */

                    @Override
                    public int compare(StudentHomeworkProcess a1, StudentHomeworkProcess a2) {
                        return (a1.getStdName()).compareTo(a2.getStdName());
                    }
                });

            } else {
                Collections.sort(unCompletedLSt, new Comparator<StudentHomeworkProcess>() {

                    /* This comparator will sort objects alphabetically. */

                    @Override
                    public int compare(StudentHomeworkProcess a1, StudentHomeworkProcess a2) {
                        return (a1.getStdNum().toString()).compareTo(a2.getStdNum().toString());
                    }
                });


            }

            mStudentsHomeworkProcessAdapter = new
                    StudentsHomeworkProcessAdapter(getActivity(), unCompletedLSt, sourceActivity);
            unCompletedLstView.setAdapter(mStudentsHomeworkProcessAdapter);

        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {

        }
    });

    return view;   
}

}