You see, I want to make a program that takes me to a web page (www.marca.com for the example).
For that, I have this XML code:
<?xml version="1.0" encoding="utf-8"?>
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webkit"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
And this Java code:
package com.example.pcx.cliente;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView browser=findViewById(R.id.webkit);
browser.setWebViewClient(new MiControl());
String cad="<html><body><a href='http://www.marca.com'>Visitar Marca</a></body></html>";
browser.loadData(cad,"text/html","UTF-8");
}
}
And here the code MiControl.java:
package com.example.pcx.cliente;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MiControl extends WebViewClient{
@Override
public boolean shouldOverrideUrlLoading(WebView browser, String url){
browser.loadUrl(url);
return true;
}
}
If I omit the part of the call to the class MyControl.java, it works in an expected way, but when even this class, I see myself with this:
What have you done wrong?