简体   繁体   English

Eclipse格式化程序:如何在我的方法中对齐代码

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

ctrl+shift+F work fine for what is inside the public class . ctrl + shift + F适用于公共类中的内容。 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 . Preferences > Java > Code Style > Formatter > Edit > Indentation Align Fields in Columns中有一个选项Align Fields in Columns 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. 但是,我找不到任何选项Align Local Variables或类似的东西。 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) 在Code Formatter(或simillar)下查看eclipse中的项目设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 vscode eclipse formatter设置对齐方法参数 - Vscode eclipse formatter setting to align method parameters Eclipse格式化程序:如何格式化注释中的数组 - Eclipse formatter: how do I format arrays in annotations 如何扩展Eclipse源格式化程序的边距? - How do I extend the margin of the Eclipse source formatter? Eclipse代码格式化程序:如何删除其效果? - Eclipse code formatter: how to remove its effects? 如何使用Eclipse JDT代码格式化程序在方法和类型注释之后插入新行? - How to insert new line just after method and type annotations using Eclipse JDT code formatter? 我怎样才能更改我的eclipse源格式化程序设置来处理以下示例? - How could I change my eclipse source formatter settings to handle the following example? 这是一个有效的方法吗? Eclipse似乎暗示我的代码存在ab问题。我只是看不到它 - Is this a valid Method? Eclipse seems to suggest there is ab issue with my code..I just do not see it 如何为 Java 代码的某些部分关闭 Eclipse 代码格式化程序? - How to turn off the Eclipse code formatter for certain sections of Java code? 如何在GridLayout中对齐复选框? - How do I align my checkboxes in a GridLayout? Eclipse Java Formatter - 对齐列中的字段; 不工作 - Eclipse Java Formatter - Align Fields in Columns; Not Working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM