Refresh Current Activity without Delay

末鹿安然 提交于 2019-12-09 11:59:41

问题


I am new to android development.So I want to refresh the current activity when Radio button clicked.When I clicked the radio button I want to change the language and refresh the current Activity without any delay.Now I click the button the current layout gone and open new one.But it takes some time.Anyone can see there is new layout coming. This is my code

Intent intent = getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
startActivity(intent);

回答1:


You can try this:

Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);

this reload's your activity without animation.




回答2:


This code may work

Intent intent = getIntent();
finish();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);



回答3:


Intent intent = new Intent(YourActivity.this, YourActivity.class);
YourActivity.this.startActivity(intent);
finish();



回答4:


Call this method when you need to refresh your activity.

recreate();




回答5:


The easiest way is to call onCreate(null); and your activity will be like new. For More info See this.



来源:https://stackoverflow.com/questions/18080135/refresh-current-activity-without-delay

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