升级后编译SDK
版本26,全部findViewById
显示错误:
没有足够的信息来推断 fun 中的参数 T
findViewById(id: Int): T!
这是因为从 Android O 开始,我们不需要强制转换它。有几种选择。代替:
val textInput = findViewById(R.id.edit_text) as TextInputLayout
与任一:
val textInput:TextInputLayout = findViewById(R.id.edit_text)
Or:
val textInput = findViewById<TextInputLayout>(R.id.edit_text)
如果你想知道幕后发生了什么,从 O 底层方法更改为
public <T extends View> T findViewById(@IdRes int id) {
return this.getDelegate().findViewById(id);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)