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);
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.
This code may work
Intent intent = getIntent();
finish();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
Intent intent = new Intent(YourActivity.this, YourActivity.class);
YourActivity.this.startActivity(intent);
finish();
Call this method when you need to refresh your activity.
recreate();
Hardik Joshi
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