View the inheritance relationship of classes in Android Studio.
The F4. this article describes the shortcut key for viewing the inheritance relationship of a class. Today, I am mainly talking about some configurations on the interface provided by this shortcut key. This feature is relatively cold and may not be used by many people. However, many android studio has similar configurations.
Not to mention nonsense. For example, if I select Activity and press F4. a diagram with an inheritance relationship with Activity appears on the right.
1. briefly analyze the following elements:
Note: The number of icons is calculated from left to right.
The first icon: displays all inheritance relationships, including parent and child classes.
Second icon: displays the parent class
Third icon: Show subclass
Fourth icon: sort by letter. This is of little use and you don't have to worry about it.
Scope: This is the range, that is, the inheritance relationship in which you want to query, and the drop-down box below is to select the range you want.
I will not talk about the following icons, and the relationship is not very big.
In addition, there are two types of inherited class icons:
Small gray lock icon: Class in source code
Without a small gray lock: Class in the current project
2. Brief Analysis of Scope:
As explained before, the classes in the source code are all downward rather than upward. For example, I will check the inheritance relationship of the Activity, if you select a range that does not display the source code, it only indicates that the child classes in the Activity source code are not displayed. If you still do not understand the scope, see the following production description.
Production: it is actually the query scope of the current project. At this time, it will hide the classes that inherit the Activity, not the current project, such as ListActivity.
All: well understood, including the project and source code.
Test: In a sense, This is the same as This Class.
This Class: current Class
Configure: Configure the query range you want to set.
The default options are the above. As for local, share is added by myself.
For example, if I select Production, for example, you will only see MyActivity, and my code contains classes that inherit from MyActivity, so there is an arrow in front of MyActivity, But I didn't expand it.
Re-select MyActivity, then press F4 to bring up the inheritance relationship diagram, select the second icon, and select the current class in the range. You can see the parent class of MyActivity.
Select the third icon. At this time, you can only see the subclass of MyActivity.
It is estimated that some people may say how I do not work when using it. It is because your Scope has a problem and you must pay attention to the Scope you choose.
3. Next I will focus on how to Configure.
1) icon and region Function Analysis
First, add Scope through configure. I added local and share. In fact, you can add two types, either local or share, you can use your own name. This is easy to describe, So we name it directly by type.
Share has a small white arrow that does not exist in local.
First icon: Add a Scope
Second icon: delete Scope
The third icon: copy a Scope. In addition to the full copy of Name, the default name is Unnamed.
The fourth icon: Save the selected Scope as. Here, sometimes you may miss it. This is a bug in Android Studio. You should turn off the dialog box, you can simply click configure again.
5. Six icons: change the position icon. For example, you can move the local icon to the share icon.
Pattern: match the range (this part will be discussed with the four buttons in the lower right)
There is a line of selectable content under the Pattern, which is actually how to display your project and the referenced package. If you think this is too messy, just ignore it. You can select different methods. The following Production Classes and Library Classes are displayed based on the display method you select.
Include, Exclude: These two are opposite. One is added, and the other is removed. They are all for Pattern. Here, they are for the addition and removal of package-level content.
Include Recursively, Exclude Recursively: These two are also opposite. add and remove Pattern content. Here we will add and remove content for the class level.
You can also click the white button next to Pattern to edit the content directly.
2) configuration parameters
Select share and copy. You can see that there is an Unnamed Scope. The Pattern content in Unnamed is the same as that in share. I will set the Pattern of share to the MyActivity class:
Set the Pattern of local to com. example. myapp. *.
After the configuration is complete, click OK and return to the inheritance relationship page. Let's take a look at the effect and select share. You will see that the subclass BActivity of MyActivity will not be queried at this time because it is not within the query range.
Select local. The range of local is the entire package. You can see that BActivity is also queried.
OK. Let's talk about this today. The next article will introduce how to use Gradle to build a project.
How to view the class inheritance diagram from the official Android documentation
Developer.android.com/reference/packages.html
Develop --- Reference
Inheritance relationship between classes and components in the android SDK
How can this problem be complete and detailed.