简体   繁体   English

如何在Android Studio / JetBrains IntelliJ IDEA中编辑模板?

[英]How to edit template in Android Studio / JetBrains IntelliJ IDEA?

I wonder to add changed "loge" template in the Android Studio editor to remove the last required param - Exception object. 我想在Android Studio编辑器中添加更改的“ loge”模板以删除最后一个必需的参数-Exception对象。 How "loge" template result looks now: 现在,“ loge”模板结果如何:

Before the dafualt template insert: 在dafualt模板之前插入:

public void doSmth() {
    //start write "loge" word here
}

After the dafualt template insert: 在dafualt模板之后插入:

public void doSmth() {
    Log.e(TAG, "doSmth: ", );
}

So to add template you have to follow several simple steps: 因此,要添加模板,您必须遵循几个简单的步骤:

  1. Open "Settings -> Editor -> Live templates -> AndroidLog" 打开“设置->编辑器->动态模板-> AndroidLog” 设置->编辑器->实时模板-> AndroidLog
  2. Click the plus button, select "1. Live Template" 点击加号按钮,选择“ 1. Live Template”
  3. Fill the fields like I did: 像我一样填写字段:
    • Abbreviation: le 缩写:le
    • Description: Log.e(TAG, String) 说明:Log.e(TAG,字符串)
    • Template text: android.util.Log.e(TAG, "$METHOD_NAME$ failed: $content$"); 模板文本:android.util.Log.e(TAG,“ $ METHOD_NAME $失败:$ content $”); 填写字段
  4. Click "Edit varables", select "methodName()" for METHOD_NAME variable 点击“编辑变量”,为METHOD_NAME变量选择“ methodName()” 编辑变量对话框
  5. One more important thing! 还有一件重要的事! Define context to Java -> Statement: 定义上下文到Java->语句: 定义Java上下文->语句
  6. Click "Apply", click "OK", Enjoy your own template! 单击“应用”,单击“确定”,享受您自己的模板! :) :)

Official documentation is here . 官方文档在这里


Your template in work: 您正在使用的模板: 您的模板在工作中 在此处输入图片说明

public void doSmth() {
    Log.e(TAG, "doSmth failed: ");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Intellij Idea中编辑方法的注释模板 - How to edit the template of comments of method in Intellij Idea IntelliJ IDEA在调试时编辑android代码 - IntelliJ IDEA edit android code while debugging 如何在 Android Studio (IntelliJ Idea) 上生成类图 (UML) - How to generate Class Diagram (UML) on Android Studio (IntelliJ Idea) 如何在Android Studio / IntelliJ Idea中添加字典以进行拼写检查 - How to add a dictionary for spell check in Android Studio / IntelliJ Idea 如何在 Android Studio 和 IntelliJ IDEA 的项目中共享 Kotlin 格式约定? - How to share Kotlin formatting conventions in project for Android Studio and IntelliJ IDEA? 如何将新的Android Studio扩展安装到IntelliJ IDEA - How to install new Android Studio extensions to IntelliJ IDEA 如何在Intellij IDEA或Android Studio中搜索未解析的库? - How to search unresolved libraries in Intellij IDEA or Android Studio? 将 JetBrains 的 Code With Me 插件与 IntelliJ 或 Android Studio 一起使用时,如何向所有成员显示设备? - Using JetBrains' Code With Me plugin with either IntelliJ or Android Studio, how can a device be shown to all members? Intellij Idea / Android Studio中的Android代码风格 - Android Code Style in Intellij Idea / Android Studio 在android studio / IntelliJ IDEA中使用标记接口 - Using marker interfaces in android studio / IntelliJ IDEA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM