java - 为什么即使没有错误,我的 Android Studio 代码也会随机出现红色下划线?
问题描述
有时即使没有错误,我的代码也会随机用红色下划线
例如,在我的 Kotlin 代码中(上面的截图):
nameTextView=findViewById(R.id.nameDashboardTextView)
ageTextView=findViewById(R.id.ageDashboardTextView)
emailIDTextView=findViewById(R.id.emailIDTextView)
genderTextView=findViewById(R.id.genderTextView)
weightTextView=findViewById(R.id.weightTextView)
heightTextView=findViewById(R.id.heightTextView)
progressBar3=findViewById(R.id.progressBar3)
任何随机变量的 findViewById 都带有红色下划线。当我复制文本,将其删除并将其粘贴回来时,“错误”被删除。此外,红线不会阻止代码编译或执行,应用程序运行良好,但在 Android Studio 中,一些随机行,如 findViewById 或其他简单的代码,将带有红色下划线。
上述示例的错误为:
无法推断类型参数 T in
有趣的 findViewById (id:Int) :T!以下替换 (Int) (Int) (Int) 均不能应用于 (Int)
知道为什么会这样吗?我正在使用 Android Studio 3.1.3,2018 年 6 月 4 日构建
解决方案
推荐阅读
- ruby-on-rails - 旧版 Rails 模态中的 vuejs 组件
- c++ - 动态内存分配表现怪异
- excel - 如何设置 Windows 类的 FreezePanes 属性?
- raspberry-pi - 同一系统上的 Mqtt 代理和 mqtt 桥接器
- json - 如何用相关模型序列化嵌套对象?
- php - 忽略以@开头的字符串中的特殊字符
- php - 有没有一种 php 方法可以在数组中多次复制一个值,而不是循环?
- javascript - 画布 - 填充在边缘留下白色像素,用于透明的 PNG 图像
- mysql - 使用“主”表上的限制和偏移量从具有一对多关系的 2 个表中获取数据
- php - Laravel 7:如何编辑验证电子邮件中的消息