How to auto complete for loop in Android studio How to auto complete for loop in Android studio android android

How to auto complete for loop in Android studio


More you can see like iter Iterate (for each..in) itin Iterate (for..in) itli Iterate over a Listitar Iterate elements of array ritar Iterate elements of array in reverse order


I found some solution.

In Android Studio, open Live Templates page. If you dont know(I didnt find it) where it is, try this.

In java code, write "fori" then press Alt+Enter, then select "Edit Live Templates Settings". You can see it in iteration section how it is done.

You can write your own templates for "Any Loop".For examples I wrote "if statement".

On iteration section or other section(whatever you want), top-right, press + icon, select Live Template, fill "Abbreviation" and description. In template text, you can search above how to make fori or ifn.

My abbreviation text is "ifi" and template text is :

if($VAR$ == true) {    $cursor$}

OR

My abbreviation text is "ife" and template text is :

if($VAR$ == true) {    $cursor$}else {}

Press Apply and OK, then in java code write ifi or ife, see what is happening :)

You do this for "try-catch, While, Switch, Foreach, Do-While or etc.".