How to define a superclass when creating a new class

I was unable to figure out how to specify the superclass when creating a new class in Android Studio. I know I can manually accomplish this with a keyword extends

, but I was wondering if there is a way to specify the superclass when creating a subclass.

+3


source to share


1 answer


The closest method I've found to achieve something like this is code files and templates. Press Ctrl + Alt + S and go to File and Code Templates in the IDE settings. You can now create your own template by clicking the green plus icon.

Here's an example of the one 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 standard class template is what I added extends ${SUPERCLASS}

. $ {SUPERCLASS} is a custom variable that will be suggested for use when using this template.

+5


source







All Articles