Marlon Paranhos
Marlon Paranhos

Reputation: 101

How can I edit a HTML in a WebView?

I want to know how to show a page only with some parts of a HTML code. Something like login and password box, login button... Is it possible to do this using only WebView?

My code:

MainActivity.java:

public class MainActivity extends ActionBarActivity {

Button enterButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final WebView myWebView = (WebView) findViewById(R.id.webView1);

WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

myWebView.setWebViewClient(new WebViewClient());

myWebView.loadUrl("http://siga.ufvjm.edu.br");

enterButton = (Button) findViewById(R.id.enterButton);
}


private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (Uri.parse(url).getHost().equals("http://siga.ufvjm.edu.br")) {
        // 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));
    startActivity(intent);
    return true;
}
}

Upvotes: 0

Views: 3303

Answers (1)

QArea
QArea

Reputation: 4981

Try to load your page with HttpClient: https://stackoverflow.com/a/4457526/3864698

After that you can customize your html code and set to WebView with loadDataWithBaseURL.

Upvotes: 1

Related Questions