Android Studio/Intellij 创意: 一个类的“目录”

我一直在使用 Android Studio,到目前为止,我喜欢我所看到的大部分东西。但有一件事一直困扰着我,那就是课堂上缺少“目录”。很抱歉我不知道该怎么称呼它。但我指的是 eclipse 中的下拉菜单,它列出了类文件中的所有方法、接口、类等等。这样你就可以跳到那个位置。此视图是当您在“ PackageExplorer”中并单击类左侧的箭头时的视图。这让我很怀念日蚀。我知道在文档中使用 Ctrl+F可以很容易地进行搜索,但是我经常忘记方法名称。我试着查看 给你,但没有用。只是想知道有没有人知道怎么处理这件事。

37567 次浏览

IDEA has a tab called "Structure", which shows all the methods, fields, etc. of the currently-open class.

IDEA window with Structure tab

I'm currently using Beta 0.8.9 of the Android Studio and what you need to do is click on the settings icon in the Android Project View. If you select 'Show Members' then the Classes become expandable and you can navigate around the class using the project view.

I've just got a Tip of the Day popup in Android Studio helping with exactly this problem.

You can quickly navigate in the currently edited file with Ctrl/+F12 (Navigate | File Structure).

It shows the list of members of the current class. Select an element you want to navigate to and press the Enter key or the F4 key. To easily locate an item in the list, just start typing its name.

Also, as danny117 points out, you can use Alt/+7 to show / hide the same content in a side panel view (shown above in Chris Jester-Young's answer).

View > Tool Windows > Structure

In addition to what Chris Jester-Young said, it's worth pointing out how to see the methods and properties of a class pointed by the cursor.

a) Type Ctrl + H in the class pointed by cursor.

b) In the class name, in the hierarchy window, double-click the class name. The system, upon confirmation, will decompile and open the class code.

c) Alt + 7 (Windows) or Command + 7 (MAC) to display the structure window.

d) One can now visualize properties, methods, derived classes, derived interfaces, and even include inherited items. All related to the class under the caret.