How to auto complete for loop in Android studio-ThrowExceptions

Exception or error:

I’m using Android studio and i’m trying to find a way to use a very common
thing i used to do in eclipse.
when i’m writing (for example) a for loop, i’m writing the word “for” then i click on Ctrl+Space and eclipse autocomplete to a for loop with all the parameters including

for (int i=0 ; i<mCheckBoxArray.length;i++){

but now, in Android studio it just auto complete to for().
the for loop its just an example,
does anybody knows how to do this in android studio?

How to solve:

You can try fori from suggestion list

enter image description here


More you can see like

iter Iterate (for
itin Iterate (
itli Iterate over a List
itar 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) {


My abbreviation text is “ife” and template text is :

if($VAR$ == true) {
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.”.

Leave a Reply

Your email address will not be published. Required fields are marked *