Y
Y
yong2019-08-21 10:38:31
Java
yong, 2019-08-21 10:38:31

Remapping in Android WebViewClient. How?

I assign settings for webViewClient. But I can't reassign from another function. Here I assign and work and correctly:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        webView = (WebView) findViewById(R.id.webView);
        webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        SimpleWebViewClientImpl webViewClient = new SimpleWebViewClientImpl(this);
        webView.setWebViewClient(webViewClient);

And after a certain event, I want to reassign this function
public void pereNaznachenie()
    {
        PereNaznachenieClass webViewClient = new PereNaznachenieClass(this);
        webView.setWebViewClient(webViewClient);

    }

Gives an error
java.lang.NullPointerException: 
Attempt to invoke virtual method 
'void android.webkit.WebView.setWebViewClient(android.webkit.WebViewClient)' 
on a null object reference

The pereAssignment function is called from here: (from an additional class)
public void onClick(DialogInterface dialog, int id) {

                                        MainActivity mActivity= new MainActivity();
                                        mActivity.pereNaznachenie();

                                        dialog.cancel();

                                    }

Help who can. Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
I'm Yoda, 2018-01-26
@Quartex

margin-left: 0;
margin-right: 0;
padding-left: 0;
parring-right: 0;

E
Eugene Chefranov, 2018-01-26
@Chefranov

It looks like indentation like bootstrap. It containershould be replaced with container-fluid. But not sure if you have Bootstrap. Not enough information.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question