When i format the code in android studio with CTRL+ALT+L my static function() set at first?-ThrowExceptions

Exception or error:

Let me explain,

When i format the code [CTRL+ALT+L].

Expected like this:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public static void myCustomFun() {
    //some code here
}

}

BUT I GOT

Result like this:

  public static void myCustomFun() {
    //some code here
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

Can any one tell me what the issue with android studio(V-3.5.3)?

How to solve:

The problem will be that you have stated you want all public or all static methods above other methods. Or you may have “keep overridden methods together”. There are a few options.

Check the arrangement tab to see what you have set:

enter image description here

(see 21,22 on my screenshot, it declares static methods above instance methods).

Leave a Reply

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