1

我想在下面进行交易时显示带有微调器的启动画面。(准备需要时间)

Fragment newFragment = new ExampleFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
transaction.commit();

起初,我尝试对呈现活动进行建模,并在事务结束时将其关闭。但是,应用程序因“onsaveinstancestate 后无法执行此操作”而崩溃。

我怎样才能做到这一点?还有另一种显示启动图像的方法吗?

4

2 回答 2

0

You should add a view in front of 'fragment_container' containing a spinner and set its visibility to VISIBLE before the transaction, and to GONE when your fragment has finished loading.

May be you will have to set this view as clickable to prevent the user from interacting with the view below.

于 2013-06-18T22:38:44.960 回答
0

名为“onsaveinstancestate 后无法执行此操作”的错误可以通过以下方式解决

transaction.commitAllowingStateLoss();

代替

transaction.commit();

是一个解释。

于 2013-09-24T13:53:52.210 回答