[英]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.