webview = (WebView) findViewById(R.id.myWebView);
出現提示:
Casting 'findViewById(R.id.myWebView)' to 'WebView' is redundant
解決方式:拿掉強制轉型
webview = findViewById(R.id.myWebView);
原因:
當選擇的 compileSDKVersion 在26之後,findViewById() 不需要強制轉型。
參考:
- https://blog.csdn.net/weiqiang_1989/article/details/80347170
批量解决Casting 'findViewById(R.id.X)' to 'X' is redundant_一笃强的博客-CSDN博客_is redundant - https://stackoverflow.com/questions/54957236/how-to-get-rid-of-this-error-casting-findviewbyid-to-edittext-is-redundant
java - how to get rid of this error 'casting findViewById to EditText is redundant'? - Stack Overflow - https://stackoverflow.com/questions/44902651/no-need-to-cast-the-result-of-findviewbyid/44903372#44903372
android - No need to cast the result of findViewById? - Stack Overflow - https://medium.com/%E5%AE%89%E5%8D%93%E5%A5%BD%E5%A5%BD%E7%8E%A9/%E6%96%87%E6%80%9D%E4%B8%8D%E8%97%8F%E7%A7%81-android-minsdkvesion-%E8%88%87-targetsdkversion-%E7%9A%84%E4%B8%8D%E8%B2%A0%E8%B2%AC%E4%BA%82%E8%AC%9B-236e61a65c6c
【安卓好好玩】Android minSDKVesion 與 targetSDKVersion 的不負責亂講 | by Vince Huang | 【安卓好好玩】 | Medium
沒有留言:
張貼留言