Android Studio activity - 使用 onCreate()、onResume() 等

Android Studio activity - using onCreate(), onResume() etc

所以,我有一个 activity,用户可以在其中查看他收集的单词。如果输入的单词存在并且仅使用可用的字母,则 he/she 将得到一个分数,该分数出现在 textView 中。

问题:

我的代码目前有这个结构,

public class calculateScoreActivity extends AppcompactActivity{
    //initialise variables to be used
    public void onCreate(Bundle savedInstanceState){
        //set variables to textViews etc
        //then go to method buttonClicked()
}

public void buttonClicked(){
    //if the button is pressed and user input is correct go to:
    updateDictionary()
    calculateScore()
}

public void updateDictionary(){
    //remove letters used in the word the user inputted
}

public void calculateScore(){
    //calculate the user score
}

我在 onCreate 之外编写这些方法是否正确?我应该在哪里以及如何使用 onPause 和 onResume 以便用户可以从他离开的地方继续?

Activity Life Cycle

阅读这张图表。使用你所处范围内的方法,我通常在 onCreate() 中完成我所有的静态设置(视图 e.t.c),然后在需要时使用生命周期的其他方法。

OnPause 将在您转到前台的 activity 之前,当您再次转到此 activity.

时将激活 onResume