The pit of AndroidStudio4.0 New Class (summary)

After AndroidStudio was upgraded, the newly created class became like this, and there is no modifier by default. I was confused by a bunch of uppercase English. Later, in

I saw the meaning of these parameters on stackoverflow  :

  • IMPORT BLOCK To put it bluntly, it is the guide package (who can write the guide package manually [cover face])
  • The value of VISIBILITY is PUBLIC or PACKAGE_PRIVATE or not filled, corresponding to public modifier, private modifier and no modifier respectively (I usually create new classes with public modifier by default, and it feels inconvenient to have no modifier by default)
  • FINAL is whether to add final modification to the class
  • SUPERCLASS is to specify the parent class
  • INTERFACES specifies the interface

Later, I found that these things are configurable, and you can modify the template according to your own needs. For template syntax, you can refer to this link:  http://velocity.apache.org/engine/devel/user-guide.html

I made some modifications to the template here:

  • I think IMPORT BLOCK is useless, so I deleted it
  • I think the uppercase is not easy to understand, so I changed it to lowercase
  • I usually create new classes that are public, so I changed the default configuration to public
  • TRUE or FALSE is too troublesome to write, so I changed it to 1 and 0

The modified template is as follows:

1

2

3

4

5

#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

 

#parse("File Header.java")

#if(${not_public_1_or_0} != "1")public #end #if (${abstract_1_or_0} == "1")abstract #end #if (${final_1_or_0} == "1")final #end class ${NAME} #if (${superClass} != "")extends ${superClass} #end #if (${interfaces} != "")implements ${interfaces} #end {

}

Click on new Class again:

have to be aware of is:

${NAME} This cannot be changed. This corresponds to the name filled in the New Java Class pop-up window. If the Name is changed, it needs to be filled in twice.

The template does not support Chinese, and an error will be reported when using Chinese

Finally, paste the template before the modification. If you want to restore the template, you can copy it from here

1

2

3

4

5

6

7

#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end

  

#if (${IMPORT_BLOCK} != "")${IMPORT_BLOCK}

#end

#parse("File Header.java")

#if (${VISIBILITY} == "public") public #end #if (${ABSTRACT} == "true")abstract #end #if (${FINAL} == "true")final #end class ${NAME} #if (${SUPERCLASS} != "")extends ${SUPERCLASS} #end #if (${INTERFACES} != "") implements ${INTERFACES} #end {

}

This is the end of this article about the pit (summary) of AndroidStudio4.0 New Class

Guess you like

Origin blog.csdn.net/iblue007/article/details/109074820