Android tutorial - How to Implement Abstract Method in Android Studio | Abstract Method - android studio tutorial
![structure of abstract class and interface](https://wikitechy.com/cdn/tutorials/android/abstract-class-vs-interface.png)
![structure of abstract class](https://wikitechy.com/cdn/tutorials/android/abstract-class-diagram.png)
What Is Abstract Method:
- The methods without body or methods with only signatures are called abstract methods.
- The abstract method doesn’t have any implementation details.
- It is declared using abstract keyword before method name.
- For example, calling method is an abstract method.
abstract void calling();
click below button to copy the code from android tutorial team
Syntax: of Abstract Method:
abstract void method_name();
click below button to copy the code from android tutorial team
Note:
- In order to use abstract method, we first need to override that method in subclass (i.e. child class).
Ways to Implement Abstract Method in Android Studio:
Method 1:
- The manual method for this in android studio is simply go to menu bar click Code -> Generate.
![implementation of abstract class menu selection](https://wikitechy.com/cdn/tutorials/android/abstract-class-implementation-select-menu-in-android-studio.png)
- On clicking will open a pop up then click over Implement Methods.
![android studio abstract class implementation](https://wikitechy.com/cdn/tutorials/android/abstract-class-implementation-in-android-studio.png)
- Further a window will open select the methods and click ok, this will implement the abstract method.
Method 2:
- In this method, just remember the shortcuts for the same task. Control + I will open the window to select implement method and click ok. Same shortcut for Mac also.
![implementation of abstract class window in android](https://wikitechy.com/cdn/tutorials/android/abstract-class-implementation-window-in-android-studio.png)