onActivityCreated()
当 Fragment 2 有代码加载数据、创建自定义数组适配器并将其设置在 ListView 上时,我需要从 Fragment 1 调用什么来强制更新/刷新 Fragment 2 ?
有没有办法更新/刷新 ListView 或者Replace()
Fragment 的意图是强制它被重建并重新运行代码onActivityCreated()
?
这是片段 2 onActivityCreated() 代码的片段:
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
// Get the prepared data and load it into this view
ArrayList<ReportData> oReportResultsData = Report.LoadData(Home.ScheduleJSonData, Home.SelectedDate);
//Set the list into the gridview (Listview formatted with rows/columns)
ScheduledActivityReportGridArrayAdapter myGridArrayAdapter = new ScheduledActivityReportGridArrayAdapter(this.getActivity(), R.layout.homeschedulerow, oReportResultsData);
lstReport.setAdapter(myGridArrayAdapter);
}
我确实尝试手动调用notifyDataSetChanged()
Fragment Manager,希望能强制它重新加载/刷新 Fragment 2。我在这里重读了文档和许多很好的答案,但是我还没有看到LoadData()
正在设置的自定义方法和自定义适配器onActivityCreated()
.
非常感谢!