Refreshing activity when dialogue is rejected
In fact, in my activity list, when the user clicks on any item, a dialog opens with two options for delete and cancel. When the user selects the delete button, the dialog is dismissed and the value in the database is deleted. And the old foreground table with old values is active. Although removed, it appears in the list. Is there any way to show the updated list. If so, how?
source to share
Please try the following code,
private final Handler handler = new Handler();
create a function: doTheAutoRefresh () that does:
private void doTheAutoRefresh() {
handler.postDelayed(new Runnable() {
doRefreshingStuff(); // this is where you put your refresh code
doTheAutoRefresh();
}, 1000);
}
Calling this function in onCreate.
NOTE: this is a basic approach. consider stopping this after onPause has been called and resume after onResume. Take a look at the handler class to see how to remove it.
source to share
Try this, implement a dialog reject manager and check if the user clicked the delete button, if yes then update
dialog.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
})
Refresh the list view by installing apdater again ....
source to share
You can override the activity method onWindowFocusChanged(boolean hasFocus)
and track the state of your activity.
Usually, if some kind of warning is displayed above your activity, the activity does not receive events onPause()
and onResume()
. But it loses focus on the displayed alert dialog and gets it when it is dismissed.
In your case, you can update your details in onWindowFocusChanged()
, if hasFocus
any true
.
source to share