Saturday, 7 September 2013

extract specific classes from html to webview

extract specific classes from html to webview

So I'm developing this android app to piggy-back off of a school web page
and retrieve specific 's within the html document. The problem is, when I
use webview in android, I'm only allowed the whole page. Can anyone help
me with understanding how to get specific parts of the html page? For
instance, from the webpage included in my code below, I have this small
bit of text from the
<div class="content"></div>
which I would like to be the only thing which shows up on the webview. Any
suggestions? Thanks in advance!
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@SuppressLint("SetJavaScriptEnabled")
public class accounts_activity_id extends Activity{
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.accounts_activity_id_main);
Initialize();
}
private void Initialize(){
WebView mainWebView = (WebView) findViewById(R.id.webView1);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.setWebViewClient(new MyCustomWebViewClient());
mainWebView.loadUrl("http://www.depauw.edu/it/onecard/");
mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
}
private class MyCustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl("http://www.depauw.edu/it/onecard/");
return true;
}
}
}

No comments:

Post a Comment