【发布时间】:2013-09-19 12:33:21
【问题描述】:
点击类MainActivity中的某个按钮时,会显示一些片段FragDialog的对话框:
FragDialog cf = new FragDialog().newInstace();
cf.show(getSupportFragmentManager(), "dialog");
当按下硬件后退按钮或关注活动MainActivity 时,对话框被关闭,我返回到活动MainActivity。
在对话框关闭后不会调用活动MainActivity 的方法onResume()、onAttach()。
这个想法是在对话框关闭后刷新活动MainActivity,以便根据对话框片段FragDialog中选择的字段获取更改后的视图。
如文档DialogFragment中所述,
// DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here.
但添加 remove() 似乎毫无意义,因为它不会被调用,即使没有它,对话框也会消失。
我想知道如果这会被调用,那么我可以再次启动活动MainActivity 以反映更改。
【问题讨论】:
标签: android android-activity refresh android-dialog