Speed code using code-completion
Use Live Templates in Android Studio
-
newInstance
- Generates the staticnewInstance
function inside a Fragment -
Toast
- GeneratesToast.makeText(context, "", Toast.LENGTH_SHORT).show();
-
fbc
- findViewById with cast -
const
- Define a android style int constant -
logd
- GeneratesLog.d(TAG, "");
-
logm
- Log current method name and its arguments. -
logr
- Log result of the current method -
logt
- static logtaf with current classname -
psf
- public static final -
sout
- Prints a string to System.out -
soutm
- Prints current class and method names to System.out -
soutp
- Prints method parameter names and values to System.out -
visible
- Set view visibility to VISIBLE -
gone
- Set view visibility to GONE -
noInstance
- private empty constructor to prohibit instance creation -
There is a quick way to surround your layout with a Linear Layout via using a Live Template. You can create one called
wrapll
by setting it up [Ref Link]...and use it as below
You can create more based on your usecase 😄
Comprehensive list of all Live Templates in Android Studio
Postfix code completion in Android Studio
Android Studio/IntelliJ havea special kind of code completion which allows you to write code specific to a field
-
<expr>.null
will auto complete toif(<expr> == null)
-
<expr>.notnull
will auto complete toif(<expr> != null)
-
<expr>.var
will auto complete toT name = <expr>
-
<expr>.field
will auto complete to create a global field variablefield = <expr>
-
<ArrayExpr>.for
will auto complete tofor(T item : <Arrayexpr>)
-
<ArrayExpr>.fori
will auto complete tofor(int i = 0; i < <Arrayexpr>.length; i++)
-
<ArrayExpr>.forr
will auto complete tofor(int i = <Arrayexpr>.length - 1; i > 0 ; i--)
Complete list of available postfix code completion can be found via navigating inside Android Studio/IntelliJ menu:
Settings → Editor → Postfix Templates