Back button and refreshing previous activity

后端 未结 11 1383
感动是毒
感动是毒 2020-12-02 06:01

If we have two activities:

  1. List of files and last modified time
  2. File editing activity

A user selects a file from the list and is taken

11条回答
  •  死守一世寂寞
    2020-12-02 06:38

    I think onRestart() works better for this.

    @Override
    public void onRestart() { 
        super.onRestart();
        //When BACK BUTTON is pressed, the activity on the stack is restarted
        //Do what you want on the refresh procedure here
    }
    

    You could code what you want to do when the Activity is restarted (called again from the event 'back button pressed') inside onRestart().

    For example, if you want to do the same thing you do in onCreate(), paste the code in onRestart() (eg. reconstructing the UI with the updated values).

提交回复
热议问题