我正在尝试从AsyncTask重新加载ListFragment,如下所示:
//set the string of the kitchen banner depending on the
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
RequestNewTopBannerFragment requestNewTopBannerFragment = new RequestNewTopBannerFragment();
Bundle argsBanner = new Bundle();
argsBanner.putString(RequestNewTopBannerFragment.ARG_KEY_BANNER_TEXT_STR, crrentTopBannerString);//this.currentRequestType ContractFoodServices.NEW_REQUEST_CONST;
requestNewTopBannerFragment.setArguments(argsBanner);
transaction.replace(R.id.fragment_container_top_banner_kitchen, requestNewTopBannerFragment) ;
transaction.addToBackStack(null);
transaction.commit();//LIGHT TIGER : commitAllowingStateLoss()
}
但是我在函数“onProgressUpdate”中执行此操作但是我得到了异常“IllegalStateException:onSaveInstanceState之后无法执行此操作” 当然,如果我将函数“commit”更改为“commitAllowingStateLoss”,它会显示相同的异常,同时,Fragment不会一直重新加载,有时会有效,有些则不会。
我试图用另一种方法从线程重新加载ListFragment,所以我尝试了这段代码:
runOnUiThread(new Runnable() {
public void run() {
RequestNewTopBannerFragment requestNewTopBannerFragment = new RequestNewTopBannerFragment();
Bundle argsBanner = new Bundle();
argsBanner.putString(RequestNewTopBannerFragment.ARG_KEY_BANNER_TEXT_STR, crrentTopBannerString);//this.currentRequestType ContractFoodServices.NEW_REQUEST_CONST;
requestNewTopBannerFragment.setArguments(argsBanner);
transaction.replace(R.id.fragment_container_top_banner_kitchen, requestNewTopBannerFragment) ;
transaction.addToBackStack(null);
transaction.commit();//LIGHT TIGER : commitAllowingStateLoss()
}
});
但它也不起作用,并显示相同的异常,那么能够从“AsyncTask”始终重新加载FragmentList的解决方案是什么
提前致谢