2

我想知道在Android Studio編輯器中添加更改的「loge」模板以刪除最後一個必需的參數 - Exception對象。 如何「包廂」模板結果現在看起來:如何在Android Studio/JetBrains IntelliJ IDEA中編輯模板?

的dafualt模板中插入前:

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

的dafualt模板中插入後:

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

回答

4

所以要添加模板,你必須遵循幾個簡單步驟:

  1. 打開「設置 - >編輯 - >實時模板 - > AndroidLog」 Settings -> Editor -> Live templates -> AndroidLog
  2. 單擊加號按鈕,選擇「1。動態模板」
  3. 滿山遍野像我一樣:
    • 縮寫:樂
    • 說明:Log.e(TAG,字符串)
    • 模板內容:android.util.Log.e(TAG, 「$ METHOD_NAME $失敗:$內容$」); Fill the fields
  4. 點擊 「編輯varables」,選擇 「方法名()」 中METHOD_NAME可變 Edit varables dialog
  5. 更重要的一件事!定義上下文到Java - >聲明: Define context to Java -> Statement
  6. 點擊「應用」,點擊「確定」,享受你自己的模板! :)

官方文檔是here


你的工作模板: Your template in work enter image description here

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

你確實努力在這個答案。感謝bro,+1:D – Vucko

相關問題