To switch Menus/Activities in Android App
public void backToMainMenu(View view){ Intent i = new Intent(getApplicationContext(), PreviousMenuClassName.class); startActivity(i); }
- I called this function in XML file as android:onClick=”backToMainMenu” in the attributes of button.
- The function must be public and have only one attribute i.e. “View view”
- You can call “i” whatever you wish.
- “PreviousMenuClassName” is the name of the Activity where you want to go after clicking the button.