2014-10-07 129 views
0

我想顯示網址欄和網頁(在URL欄下方)。但我不知道爲什麼它只顯示網頁。爲什麼WebView中不顯示地址欄?

XML代碼:

<EditText 
    android:id="@+id/etURL" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 

    android:inputType="text"   
    /> 

<WebView 
    android:id="@+id/webview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/etURL" 
/> 

Java代碼

webView = (WebView) findViewById(R.id.webview); 
WebSettings ws = webView.getSettings(); 

ws.setJavaScriptEnabled(true); 
ws.setSupportMultipleWindows(true); 
ws.setSupportZoom(true); 
ws.setBuiltInZoomControls(true); 
ws.setCacheMode(WebSettings.LOAD_NO_CACHE); 
ws.setUseWideViewPort(true); 
ws.setLoadWithOverviewMode(true); 
ws.setLoadsImagesAutomatically(true); 
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 

webView.loadUrl(mURL); 
MyWebViewClient wvc = new MyWebViewClient(); 
webView.setWebViewClient(wvc); 
wvc.setActivity(this); 
wvc.setListener(this); 

我想,地址欄是由網頁覆蓋。如何在地址欄下方顯示網頁?

+0

如果我記得正確的是webclient相關的東西。嘗試運行相同的沒有'webView.setWebViewClient(wvc);' – Blackbelt 2014-10-07 12:51:42

+0

刪除完整的'wvc'部分。但它沒有運行@blackbelt – SGG 2014-10-07 12:58:58

+0

*沒有運行什麼*意思是 – Blackbelt 2014-10-07 12:59:37

回答

0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.networkex.WebViewActivity$PlaceholderFragment" > 

    <EditText 
     android:id="@+id/etURL" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:inputType="text" /> 

    <WebView 
     android:id="@+id/webView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/etURL"/> 

</RelativeLayout> 

這種組合對我很有幫助。試一試。