Is there any auto-complete shortcut or code-generation command in Android Studio that creates a stub
switch (myEnum){
}
statement containing all of the possible case
statements for a defined enum
as in Eclipse?
Is there any auto-complete shortcut or code-generation command in Android Studio that creates a stub
switch (myEnum){
}
statement containing all of the possible case
statements for a defined enum
as in Eclipse?
Put the caret on "switch", press Alt-Enter, select "Create missing 'switch' branches".
Enum.class
public enum
myEnum{
Item1,
Item2,
Item3,
Item4
}
EnumSwitchImplement.class
private Enum.myEnum mMyEnum;
switch(mMyEnum){
//put cursor here and press Alt + Enter
/*a box will come with option "create missing 'switch' branches"
select.*/
}
//your switch will convert to
switch(mMyEnum){
case Item1:
break;
case Item2:
break;
case Item3:
break;
case Item4:
break;
}
This works on Android Studio. Haven't check on Eclipse. :)
Just place the mouse pointer over switch
and then wait for some time. An yellow bulb will be shown as below. Click on that yellow bulb (or press ALT+Enter) and click on the option Create missing 'switch' branches
option.
This will auto create the switch case-break statements as below.
Hope this helps someone.