如何在Android Studio IDE中查看变量的类型

时间:2019-07-19 19:42:07

标签: android android-studio kotlin

在没有类型注释的情况下使用Kotlin时如何在Android Studio中查看变量的类型。

当前,我正在尝试通过给变量提供一个我知道的错误类型来查看它,并且IDE会通知我有关期望类型的错误。

val variable = dont().know().type().ofThis()

举个例子,我可以按CTRL + P来查看函数的签名,是否有类似的方法来查看变量的推断类型?

2 个答案:

答案 0 :(得分:3)

“查看”菜单中有一个菜单项:“类型信息”

在Android Studio Win 3.5.3中

Ctrl + Shift + P

答案 1 :(得分:2)

您可以为此启用Parameter name hints

Example of type hints

为此,请转到File-> Settings-> Editor-> General-> Appearance并检查Show parameter name hints 。确保单击configure按钮,然后在Options面板上,检查所需的选项,包括show local variable type hints

Enable type hints Type hints configuration