Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating UI after dialog dismissed

I have activity A which have a ListView with custom adapter.

The custom adapter (which aplies to each list view item) have a button which invokes a custom dialog.

in this dialog an action is being performed which in response i want to invoke UI update on activity A.

This is my activity on resume code:

@Override
public void onResume() 
{
    super.onResume();
    setUI();  
}

But when the i call

dialog.dismiss();

The dialog closes without the Activity A OnResume method benig invoked.

How can i catch and update the activity ui?

like image 759
Michael A Avatar asked Oct 24 '25 18:10

Michael A


1 Answers

You can set an OnDismissListener to your dialog to achieve this:

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setOnDismissListener(listener);
...
Dialog dialog = builder.create();

You can let your Activity impelement DialogInterface.OnDismissListener and set them as the listener, so they get notified in the method onDismiss(DialogInterface dialog). In there, you can update your UI.

like image 94
tknell Avatar answered Oct 27 '25 08:10

tknell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!