简体   繁体   English

我的网络视图不起作用。 找不到符号?

[英]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.

相关问题 我的回收视图不起作用。 你能帮助我吗? - My recycleview isn't working. Can you help me? 我用于查找阶乘的代码不起作用。 请有人找出错误 - My code for finding factorial is not working. Please somebody find the error 我尝试在我的小型 android 项目中使用意向电子邮件,但它不起作用。 谁能帮我找出错误? - I tried to use intent email in my small android project but its not working. Can anyone help me to find the error? 我的 AppCompatActivity 不工作。 为什么这样? - My AppCompatActivity isn't working. why so? 我的JavaFX计时器不起作用。 为什么? - My timer for JavaFX isn't working. Why? Java编译器为什么找不到符号? - Why can't the Java compiler find symbols? 我在Java中的循环无法正常工作。 谁能看到原因? - My loop in java is not working. Can anyone see why? 关于程序的最后一点,我无法正常工作。 (建设者) - Final bit on program I can't get working. (Constructors) 我的鼠标听众似乎没有工作。 有人能帮我吗? 我必须将球移动到单击鼠标的位置,但它不起作用 - My mouse listeners don't seem to be working. Can someone help me? I have to move a ball to where my mouse is clicked and it is not working 错误 - 找不到符号“webview” - error - can't find symbol "webview"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM