Add a New method to an Activity

API Level 1

1. Create a new Android project, if you don't already have one.

2. In the MainActivity.java file, add the below code after the onCreate method. This will create a new method named myMethod.

private void myMethod() {
}

3. Compile and run!

Next Recommended Article: How to Call a Method

Resources: