简体   繁体   English

为什么Android无法识别loadurl方法?

[英]Why is android not recognizing the loadurl method?

if (mItem != null) {
    (WebView)rootView.findViewById(R.id.apple).loadUrl(mItem.urls);
}

return rootView;

I don't know why android is not recognizing this method and counting it as an error. 我不知道为什么Android无法识别此方法并将其视为错误。 (the loadurl method with the arrow underneath) I am trying to load the webpage from the m items into the webview. (带有下面箭头的loadurl方法)我试图将网页从m个项加载到webview中。

The cast is incomplete/misplaced. 演员表不完整/放错了位置。 This is probably what you meant: 这可能是您的意思:

((WebView)rootView.findViewById(R.id.apple)).loadUrl(mItem.urls);

The cast, as you placed it, casts the expression rootView.findViewById(R.id.apple).loadUrl(mItem.urls) to a WebView , which doesn't make sense. 转换后,将表达式rootView.findViewById(R.id.apple).loadUrl(mItem.urls)转换为WebView ,这是没有意义的。 You want to carry specifically rootView.findViewById(R.id.apple) . 您要专门携带rootView.findViewById(R.id.apple)

The type of the value returned by findView is View , not a WebView , hence the compiler error you got. findView返回的值的类型是View ,而不是WebView ,因此您遇到了编译器错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM