0

次のようなxmlレイアウトファイルがあります。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"  android:background="#262626">

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="EXIT" />

 <ScrollView
        android:id="@+id/sv2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="10dp" android:background="#ffffff">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <WebView
                android:id="@+id/add_webView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:scrollbarStyle="insideOverlay"
                android:text="@string/desc" />

        </RelativeLayout>
    </ScrollView>
</LinearLayout>

アプリに URL をロードし、webView の上に作成したボタンを保持したいと思います。残念ながら、デバイス ブラウザの新しいウィンドウに webView が表示されます。

これは私がwebViewを呼び出す方法です:

WebView add_webView = (WebView) dialog
                    .findViewById(R.id.add_webView);

            add_webView.loadUrl(MYLINK);

ブラウザー ウィンドウではなく、アプリに webView を表示するにはどうすればよいですか? ありがとう!!:)

4

1 に答える 1

0

ダイアログでwebViewが欲しいので、解決策はsetWebClient()を使用することでした

AlertDialog.Builder アラート = new AlertDialog.Builder(this);

    alert.setTitle("Title here");
    WebView wv = new WebView(this);

    wv.loadUrl("http:\\www.google.com");

    wv.setWebViewClient(new WebViewClient()
    {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {
            view.loadUrl(url);

            return true;
        }
    });

    alert.setView(wv);
    alert.setNegativeButton("Close", new DialogInterface.OnClickListener()
    {
        @Override
        public void onClick(DialogInterface dialog, int id)
        {
        }
    });
    alert.show();
于 2013-04-15T19:04:57.867 に答える