WebViewClient cannot be allowed for type

This is a republishing of the question I asked last week, received 2 answers that did not work.

I followed the manual http://developer.android.com/resources/tutorials/views/hello-webview.html , and then created my own EditText field and button. the code should explain all this, my problem is that I keep getting "HelloWebViewClient cannot be resolved to type" Error, any suggestions? thanks in advance!

    package com.text.text;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;

public class test extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alt);
        final EditText edittext = (EditText) findViewById(R.id.edittext);
        final Button button = (Button) findViewById(R.id.okay);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Editable text = edittext.getText();
                String Tekst = text.toString();
                setContentView(R.layout.main);
                WebView mWebView;
                mWebView = (WebView) findViewById(R.id.webview);
                mWebView.getSettings().setJavaScriptEnabled(true);
                mWebView.loadUrl(Tekst);
                mWebView.setWebViewClient(new HelloWebViewClient());
                class HelloWebViewClient extends WebViewClient {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        view.loadUrl(url);
                        return true;

                    }
        };
    }
});
}}
+3
source share
2 answers

I had this problem too, and the problem turned out to be that the following missing packages were not imported (you already have one in your source:

import android.webkit.WebView;
import android.webkit.WebViewClient;

, CommonsWare, - .

+10

HelloWebViewClient onCreate() ( test). , .

+1

Source: https://habr.com/ru/post/1782819/


All Articles