I have not been able to figure out how to specify a superclass when creating a new class in Android Studio. I know I can manually accomplish this using the extends
keyword but I was wondering if there was a way to specify superclass while creating the subclass.
The closest method I have found to achieve something similar is File and Code Templates. Press Ctrl+Alt+S and go to File and Code Templates in the IDE Settings. Now you can create your own template by clicking on the green plus sign.
Here's an example of one that I created based on the Class Template:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} extends ${SUPERCLASS} {
}
The only difference between this and the default Class template is that I've added extends ${SUPERCLASS}
. ${SUPERCLASS} is a custom variable which will be prompted to be used when using this template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With