java – WebView on Android, editing HTML


I am able to load the URL on my device using WebView , but the page that loads is not mobile-friendly. I would like to know if I can access the page, but eliminating some parts of the HTML. Code below:

public class MainActivity extends ActionBarActivity {

Button btEntrar;

protected void onCreate(Bundle savedInstanceState) {

final WebView myWebView = (WebView) findViewById(;

WebSettings webSettings = myWebView.getSettings();

myWebView.setWebViewClient(new WebViewClient());


btEntrar = (Button) findViewById(;

private class MyWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (Uri.parse(url).getHost().equals("SITE DESEJADO")) {
        // This is my web site, so do not override; let my WebView load the page
        return false;
    // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    return true;

I want to leave only the login field, password and login button, and then pass it on normally.


You can use the loadData method. To learn more about the loadData method and also about other methods that can be used in your case, consult the documentation .

Example of use:


String example = "<html><body>My first body<b>LIKE</b> mee.</body></html>";
webview.loadData(example, "text/html", null);
  • Sample code available in documentation.


Scroll to Top