1
这是手动刷新活动的正确方法吗?刷新Android应用程序活动
....
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);
看到这种方法破坏活动并重新创建它,我流浪了,它可能是一种昂贵的方法。
您不能只更新活动的内容吗?我建议你在你的activity上创建一个init()方法来设置内容,然后调用这个方法,而不是在onCreate方法中做所有你需要的东西 – GhostDerfel
如果你想刷新并重新创建activity,使用'recreate()'方法。 .. –
最简单的方法是调用onCreate(null);你的活动就像新的一样 –