由网友(尽成空)分享简介:我有在重新启动一个活动一片混乱。我有两个功能非常适用于相同的任务。请指导我哪一个是最好的,为什么? I am having a confusion in restarting an activity.. I have two function that works well for the same task. P...
我有在重新启动一个活动一片混乱。我有两个功能非常适用于相同的任务。请指导我哪一个是最好的,为什么?
I am having a confusion in restarting an activity.. I have two function that works well for the same task. Please guide me which is best and why?
public void restart()
{
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(R.anim.fade,R.anim.fade);
startActivity(intent);
}
或
public void restart()
{
onCreate();
}
在此先感谢?
Thanks In advance?
推荐答案
我觉得这是对你的要求,更清洁的方式。
I think this is a cleaner way for your requirement.
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
相关推荐
最新文章