[英]My webview is not working. Can't find symbols?
My error is that cannot find symbol class WebViewClient, and cannot find symbol class WebChromeClient huhu i tried everything in tutorials..我的错误是找不到符号类 WebViewClient,也找不到符号类 WebChromeClient huhu 我尝试了教程中的所有内容..
This is my MainActivity.java:这是我的 MainActivity.java:
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {
WebView superWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
superWebView = (WebView) this.findViewById(R.id.myWebView);
superWebView.loadUrl("https://www.google.com");
superWebView.getSettings().setJavaScriptEnabled(true);
superWebView.setWebViewClient(new WebViewClient());
superWebView.setWebChromeClient(new WebChromeClient(){
@Override
public void onReceivedIcon(Webview view, Bitmap icon) {
super.onReceivedIcon(view,icon);
}
});
}
}
This is my activity_main.xml:这是我的activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<WebView
android:id="@+id/myWebView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
This is my AndroidManifest.xml这是我的 AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
This is my first try in trying webview in android studio.. installed sdks and such.. i dont know if i missed some things..这是我第一次尝试在 android studio 中尝试 webview.. 安装了 sdks 等等.. 我不知道我是否错过了一些东西..
I was supposed to view a website or google in relative layout but JAVA can't seem to find the sysmbol.. need helped thanks a lot!我应该以相对布局查看网站或谷歌,但 JAVA 似乎无法找到 sysmbol .. 需要帮助,非常感谢!
In order to use onReceiveIcon()
, you should use setWebChromeClient .为了使用
onReceiveIcon()
,您应该使用setWebChromeClient 。
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
progressBar.setProgress(newProgress);
}
@Override
public void onReceivedIcon(WebView view, Bitmap icon) {
super.onReceivedIcon(view, icon);
webImage.setImageBitmap(icon);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.