Custom Android Studio method annotation template, androidstudio

Source: Internet
Author: User

Custom Android Studio method annotation template, androidstudio

Preface

When you switch from Eclipse to Android Studio, will you miss the Eclipse method annotation template?

When you press/** and press enter, the template is displayed, but Android Studio cannot be customized (or I cannot find it)

Now I have found an alternative, that is, using live templates.

 

Procedure

1. File-> Setting-> Editor-> Live Templates

2. Click + to create a Template Group.

2. Enter the group name you want. My name is custom.

3. Select the group you just created and create a Live Template

4. Fill in Abbreviation. Here I fill in the cmt, that is, the shortcut for your comment. When you press cmt and press enter, the template will come out.

Template text is a annotated Template. You can write any Template as needed. My Template is as follows:

5. To set where your cmt shortcut will take effect, my choice is to take effect at the time of declaration, that is, you can press cmt and press enter on the method name.

6. I noticed that my Template text defines three variables: desc, date, and time. The next two variables are generated by date and time. Therefore, we need to edit these two variables.

Click Edit variables. In the displayed window, set the corresponding method for date and time. The date () method generates the date and time () method generates the time.

7. Click Apply. Now, you only need to press cmt on the method name and press enter to automatically generate the annotation template. The effect is as follows, and the time is automatically generated.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.