|
Android
Development Starter Guide using Android Studio Moving from One Activity to Another Step 1: Create a button in your Main Activity. Refer to the tutorial on Creating a Functional Button. Link Step 2: Add in the onClick method into your button. Lets call it nextActivity. Step 3: Add in the nextActivity method in the MainActivity java file. This method will have to take in a View object.
Step 4: We are going to create another activity. File->New Activity->Blank Activity . Will use the default name MainActivity2Activity. Step 5: Going back to MainActivity, we will write code in the nextActivity method to move to the MainActivity2Activity screen. See the comments in the code to see what's going on. //In MainActivity.java Step 6: Run the code. Click the button in MainActivity. It should move from the MainActivity page to MainActivity2Activity. to |