2013-10-28 168 views
0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <WebView 
     android:id="@+id/mapview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1.0" /> 
     <LinearLayout android:id="@+id/TableRow05" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="47dp"> 
      <Button android:text="@string/Start" android:id="@+id/StartButton" android:layout_height="wrap_content" android:layout_width="100dp" android:textSize="20sp" ></Button> 
      <Button android:text="@string/Exit" android:id="@+id/QuitButton" android:layout_height="wrap_content" android:layout_width="100dp" android:textSize="20sp"></Button> 
     </LinearLayout> 
     <Button android:text="@string/Stop" android:id="@+id/StopButton" android:layout_height="wrap_content" android:layout_width="100dp" android:textSize="20sp" android:layout_marginLeft="97dp"></Button> 

</LinearLayout> 

這是我的佈局的xml文件。我想在webview下添加其他東西(一些按鈕,如示例中的那些按鈕)。問題是,如果我打電話給loadUrl(string)方法,我會得到一個全屏頁面(我必須回到應用程序)。我能做些什麼才能在網頁的上半部分看到網頁?Android WebView和其他東西

回答

1

工作對我試試這個:

WebView myWebView = (WebView) findViewById(R.id.mapview); 

class MyWebViewClient extends WebViewClient { 
      @Override 
      public boolean shouldOverrideUrlLoading(WebView view, String url) { 

        view.loadUrl(url); // Stay within this webview and load url 
        return true; 
      } 

    } 

myWebView.setWebViewClient(new MyWebViewClient()); 
myWebView.loadUrl("YOUR URL"); 
+0

和MyWebViewClient裏面? –

+0

我忘了什麼^ ^編輯:) – Graya

+0

它的工作原理,非常感謝。 –

0

這在過去

<RelativeLayout android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"> 

    // WebView 
</RelativeLayout> 
//Buttons 
+0

還是同樣的問題。 webview實際上是在上半部分,但是當我調用'loadUrl(string)'時,應用程序會打開一個全屏瀏覽器頁面。 –

+0

你能顯示loadURL(string)方法嗎? – BigT

+0

'myWebView.loadUrl(「http://maps.google.com/maps?q=43.0054446,-87.9678884&t=m &z=7");'。這不是我創建的方法。 –