質問

The jump bar in Xcode and #pragma mark in Objective-C are very helpful and I'm looking for anything similar in Android Studio (either native or by plug-in).

役に立ちましたか?

解決

In Android Studio you can add regions using the steps below

  1. Open the IDE you are using
  2. Select the code you want to group
  3. Press Ctrl + Alt + T (Cmd + Opt + T for mac) and select the “region .. end region comments”
  4. Now the code is surrounded with “//region” / “//endregion” lines, you can see that the region can be fold-able
  5. You can now edit the description of your group
  6. You can easily see the code within your group without having to expand the group, just hover the group description with the mouse pointer

See this

他のヒント

Meet custom folding regions, the IntelliJ IDEA (where Android Studio is derived from) way to customized code structure support (that is what jump bar serves in Xcode).

Keyboard shortcut ⌥⌘T or manual typing,

// region REGION_NAME
// YOUR CODE HERE
// endregion

Here is the missing gif demo (that people want in their official doc) showing how Android Studio behaves when two customized regions are added.

demo

Official Documentation

https://www.jetbrains.com/help/idea/code-folding-settings.html

No idea why answers by Android Developers mostly lacking clarity. Here is my contribution.

Simply said, just wrap the codes with

//region SECTION NAME
...
//endregion

enter image description here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top