Android Studio Live Templates


Auto-Generated Live Templates in Android studio

Auto generating live templates are useful when your writing code in Android Studio IDE.  You can enable this feature from the following the path 

Editor >> Live Templates >> AndroidLog





Some templates for android/java developers:

psfs -     public static final String
psf -     public static final
psfi -     public static final int
psvm -     public static void main(String[] args) {}
fixme -     // FIXME: 02-12-2019
geti -     public static MainActivity getInstance() {     return ;   } - Instert singlton method get instance
key -     private static final String KEY_ = ""; - key for the bundle
fori -        for (int i = 0; i < ; i++) {}
foreach -
ifn - if null statement
inn - if not null
inst - instance
lazy - perform lazy initializer
lst - fetch last element of an array
rgs - get a string from resource
rouit - Run on ui thread
ritar - Iterate element of array in reverse order

Android LOG tempaltes: 

logt - private static final String TAG = "$className$";
          private static final String TAG = "MainActivity"; - A static logtag with your current  classname
logd - android.util.Log.d(TAG, "$METHOD_NAME$: $content$");
          Eg: Log.d(TAG, "onCreate: ");
loge - android.util.Log.e(TAG, "$METHOD_NAME$: $content$", $exception$);
          Eg:  Log.e(TAG, "onCreate: ", e);
logi - android.util.Log.i(TAG, "$METHOD_NAME$: $content$");
          Eg: Log.i(TAG, "onCreate: ");
logm - android.util.Log.d(TAG, $content$);
          Eg:  Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");
logr - android.util.Log.d(TAG, "$METHOD_NAME$() returned: " +  $result$);
          Eg: Log.d(TAG, "onCreate() returned: " + );
logw - android.util.Log.w(TAG, "$METHOD_NAME$: $content$", $exception$);
          Eg: Log.w(TAG, "onCreate: ", e);
wtf - android.util.Log.wtf(TAG, "$METHOD_NAME$: $content$", $exception$);
   

Android XML templates

appNs - xmlns:app="http://schemas.android.com/apk/res-auto"
toolsNs - xmlns:tools="http://schemas.android.com/tools"lh - android:layout_height="$height$"
lhm - android:layout_height="match_parent"
lhw - android:layout_height="wrap_content"
lw - android:layout_width="$width$"
lwm - android:layout_width="match_parent"
lww - android:layout_width="wrap_content"

Comments

Popular posts from this blog

Google Assistant Implementation in Android application with app actions