0
我想知道如何僅顯示HTML代碼的某些部分的頁面。就像登錄和密碼框,登錄按鈕...有沒有可能只使用WebView做到這一點?如何在WebView中編輯HTML?
我的代碼:
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;
}
}
代碼的哪部分不起作用?你不需要發佈你的整個代碼,GUI和所有 - 只需發佈失敗的部分。 – Hosch250 2014-11-03 00:20:58
沒有失敗的部分。我的疑問是:如何只顯示我想要的HTML部分?如何編輯並使其在我的應用程序中工作。 換句話說,我想加載HTML頁面,但只顯示「用戶」,「密碼」框和「登錄」按鈕。 謝謝。 – Marpd144 2014-11-03 00:36:59
我從來沒有這樣做過,所以我不知道如何解決你的問題。作爲我以前的評論的重申,您應該公佈解決問題的最小代碼嘗試,而不是您的整個工作解決方案。我希望有人能儘快幫助你! – Hosch250 2014-11-03 01:22:27