Refreshing Activity When Dialog Dismisses

2019-04-14 14:33发布

Actually in my list activity,when user taps on any item ,a dialog box is opened with two options of delete and cancel.When user select delete button the dialog dismisses with deleting value in database.And the old list activity comes in foreground with old values.Though it is deleted it is showing in listview.Is there a way to show the refreshed list.If yes,then How?

7条回答
手持菜刀,她持情操
2楼-- · 2019-04-14 15:03

You can override activity method onWindowFocusChanged(boolean hasFocus) and track the state of your activity.

Normally, if some alert dialog is shown above your activity, the activity does not get onPause() and onResume() events. But it loses focus on alert dialog shown and gains it when it dismisses.

In your case you can refresh your data in onWindowFocusChanged() if hasFocus is true.

查看更多
登录 后发表回答