1. Custom annotations

1.1, Androidstudio menu bar go to FIle – > Settings – > Editor to find Live Templates. If you cannot find Live Templates, search for it.

     

1.2, click the + sign on the right of the figure above to select Template Group, create a Template Group, and fill in the name of Template Group. Fill in the name according to your actual situation.

1.3, select the Template Group you just created and click the + sign again to create a Live Template

1.4. Select the newly created Live Template and fill in the Abbreviation (the name of the shortcut key) for easy input and memory. Enter add. Add is a shortcut to this comment. Type Add + Enter at the top of the class body to create a custom comment template.

1.5. Enter the comment template in TemplateText: Note: I entered the Eclipse comment template, so my Edit variables button is not clickable (AndroidStudio cannot identify the comment template). {user} ${AS} ${AS} ${AS} ${AS} ${AS} ${AS} ${AS} ${AS} ${AS

** * @title: ${file_name} * @package ${package_name} * @description: ${todo} * @author ${user} * @date ${date} * @version V1.0 */ / androidStudio annotation template /** * @title: $file_name$* @package $package_name$* @description: $todo$* @author $user$* @date $date$* @version V1.0 */Copy the code

1.6. Click Define first, the window for selecting comments for development language will pop up; I do Android, of course, Java and Kotlin, Java and Kotlin, respectively, select the annotation template generation location; Finally, select Enter in the Expand with position, that is, Enter Add + Enter to automatically generate the comment;

1.7, assign values to variables. If you do not set the development language and the effective location of the comments in step 1.6, variables such as date and user will not take effect, nor will they be generated when shortcut keys generate comments. Click Edit Variables and set the variables as shown below

2. The generated comment is as follows (for example, enter add+ Enter to generate the following comment template) :

/** * @Title: MainActivity * @Package com.ang.demo.test * @Description: (Describe in one sentence what the file does) * @author Ang * @date 2018/9/15 * @version V1.0 */Copy the code

If it will help you

Might as well add a concern, a point of praise ha, your every small move is a great support to me!