How to restart the onCreate function

会有一股神秘感。 提交于 2019-11-29 04:34:42

How about creating a method outside of your onCreate() that does all of the Activities work, and in your onCreate method, it calls that to load the Activity. If you need to refresh your Activity, just call that new method. For example:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    loadActivity();
}

private void loadActivity() {
    // Do all of your work here
}

private OnClickListener ReloadActivity = new OnClickListener() {
    public void onClick(View v) {
        loadActivity();
    }
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!