Android: Reset onClick Activity

I have activity, and at this event there are several buttons that do different things with numbers, etc. At some point, although I would like to have the user reset / (restart?), To return to its original state without clicking the back button or restarting the application.

I want to create a reset button. I know how to make a button myself, but I don't know how to reset activity.

@Override public void onClick(View v) { switch (v.getId()) { case R.id.button1: // do stuff break; case R.id.button2: // do stuff break; case R.id.button3: // do stuff break; case R.id.reset: // what goes here? default: break; } } 

How it's done?

+4
source share
1 answer

This will start your activity.

 @Override public void onClick(View v) { switch (v.getId()) { case R.id.button1: // do stuff break; case R.id.button2: // do stuff break; case R.id.button3: // do stuff break; case R.id.reset: Intent intent = getIntent(); finish(); startActivity(intent); default: break; } } 

You can add the following to get rid of fantastic animations.

 overridePendingTransition(0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 
+12
source

All Articles