$scope.$on('event_name', function () {
//data required to pass in parent controller
});
有MainActivity
个Fragments
,其中包含使用自定义TabLayout
和ViewPager
的嵌套片段。每个Fragment
嵌套片段都会使用ListView
向WebServices
显示数据。
它们的一个片段是:
public class IndicesFragment extends android.support.v4.app.Fragment {
public static IndicesFragment newInstance() {
return new IndicesFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.equity_activity, container, false);
act = this.getActivity();
return view;
}
public void onActivityCreated(Bundle savedInstanceState1) {
super.onActivityCreated(savedInstanceState1);
setHasOptionsMenu(true);
list = (ListView) view.findViewById(R.id.list_equity);
if (Utils.isNetworkAvailable(getActivity())) {
if (catListDao.size() > 0) {
adapter = new AdvisorsAdapter(act, R.layout.custom_equity, catListDao, 0);
list.setAdapter(adapter);
} else {
if (!isViewShown) {
new FetchAllData(getActivity(), 3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
} else {
CustomToast toast = new CustomToast(getActivity(), "There is no internet connection!");
}
}
@Override
public void onResume() {
super.onResume();
Constants.check_fragment_visible = 1;
if (Constants.check_reload) {
if (Utils.isNetworkAvailable(getActivity())) {
new FetchAllData(getActivity(), 3).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
CustomToast toast = new CustomToast(getActivity(), "There is no internet connection!");
}
}
if (adapter != null) adapter.notifyDataSetChanged();
}
当我们从Dialog
更改Activity
并且从{{1}的另一个片段调用此嵌套片段时,我的应用程序在没有任何Fragment
的情况下崩溃它被冻结在那里,嵌套片段的结果突然在那里被打开了。挂起线程的 StackTrace 就像:
MainActivity