简体   繁体   中英

Eclipse formatter: how do I align the code in my method

ctrl+shift+F work fine for what is inside the public class . but the formatting does not work inside the method, see the = sign is not aligned. why? and how do I get this to work?

public class myClass extends ActivityInstrumentationTestCase2 {
    public static boolean       myVar                            = true;
    private static final String TARGET_PACKAGE_ID                = "com.xxxx.test";
    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.xxxx.test";
    private static Class        launcherActivityClass;

...
...
private String getOnScreeninfoByType() {
        ArrayList<TextView> textViews = new ArrayList<TextView>();
        ArrayList<Button> listButtons = new ArrayList<Button>();
        ArrayList<ToggleButton> listToggleButtons = new ArrayList<ToggleButton>();
        ArrayList<EditText> listEditTexts = new ArrayList<EditText>();
        ArrayList<CheckBox> listCheckBoxes = new ArrayList<CheckBox>();
        ArrayList<RadioButton> listRadioButtons = new ArrayList<RadioButton>();
        ArrayList<ImageButton> listImageButtons = new ArrayList<ImageButton>();
        ArrayList<ImageView> listImageViews = new ArrayList<ImageView>();
        ArrayList<ProgressBar> listProgressBars = new ArrayList<ProgressBar>();
...

    }

thanks

There is an option Align Fields in Columns in Preferences > Java > Code Style > Formatter > Edit > Indentation . If this option is checked, fields in class are aligned as you saw. However, I couldn't find any options Align Local Variables or something like that. It seems that there is no option to align local variables in columns.

They are not aligned because they should not be aligned!
The special alignment in the class, could be caused by a special non standard formating rule, that was set up by the person which created that project. Look in project settings in eclipse under Code Formatter (or simillar)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM