webview摆脱地址栏?

时间:2013-10-26 23:28:08

标签: android webview

一直在阅读如何摆脱地址栏,它似乎没有多大意义。

有帖子谈论添加一行代码,但我似乎无法放置它。

此     WebView.setWebViewClient(new WebViewClient());

Main.java

package com.webapp.area956;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {





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

    WebViewClient yourWebClient = new WebViewClient()

        {
           // Override page so it's load on my view only
           @Override
           public boolean shouldOverrideUrlLoading(WebView  view, String  url)
           {
            // This line we let me load only pages inside Firstdroid Webpage
            if ( url.contains("area956") == true )
               // Load new URL Don't override URL Link
               return false;

            // Return true to override url loading (In this case do nothing).
            return true;
           }
       };

    String url = "http://www.area956.com";
    WebView view = (WebView) this.findViewById(R.id.webView1);

    view.getSettings().setJavaScriptEnabled(true);
    view.loadUrl(url);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

1 个答案:

答案 0 :(得分:0)

在这种情况下你会打电话给

view.setWebViewClient(yourWebClient);
找到webView后

WebView view = (WebView) this.findViewById(R.id.webView1);