Refreshing an android app activity

↘锁芯ラ 提交于 2019-12-11 09:18:00

问题


Is this A correct way to manually refresh an activity?

....
case R.id.action_refresh:
        Intent i = new Intent(Homepage.this, Homepage.class);
        Toast.makeText(Homepage.this, "refreshing", Toast.LENGTH_LONG).show();
        finish();
        startActivity(i);

seeing that this method destroys the activity and recreates it, i was wandering weither it may be to much of a costly method.


回答1:


The method given by you is a standard one. But if you need another method you can use the following method

 onCreate(null)


来源:https://stackoverflow.com/questions/21736610/refreshing-an-android-app-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!