打开web视图没有新的浏览器视图、浏览器、web

2023-09-12 03:29:16 作者:悲伤的季节

我在执行一个web视图。我想在网页顶部的两个按钮。

I am implementing a webview. I want two buttons on the top of the web page.

我有一个垂直线性布局,其内部是一个带有两个按钮中的一个横向布置,和一个web视图横向布置的外

I have one vertical linear layout, inside of which is one horizontal layout with two buttons, and one webview outside of the horizontal layout.

我只是加载谷歌URL中的Java code。

I am simply loading the Google URL in Java code.

我每次运行应用程序,它会打开的应用程序之上的新的浏览器和按钮获取隐藏。它没有显示web视图上方的按钮。 请帮忙,告诉我怎么可以在web视图加载的URL,而无需打开其他浏览器,或者我怎么能prevent通过打开一个原生浏览器,从而使页面加载web视图本身,而不是一个新的浏览器。

Every time I run the application, it opens a new browser on top of the application and the buttons get hidden. It's not showing the buttons above the webview. Please help and tell me how can I load a URL in the webview without opening another browser, or how I can prevent it by opening a native browser, so that the page is loaded in the webview itself and not a new browser.

感谢所有

推荐答案

的布局应与此类似:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_height="fill_parent"
                 android:layout_width="fill_parent"
                 android:orientation="vertical">
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Button android:id="@+id/button1"
                android:layout_width="0dip"
                android:layout_height="wrap_content"                
                android:layout_gravity="top"
                android:layout_weight="1"/>
            <Button android:id="@+id/button2"
                android:layout_width="0dip"
                android:layout_height="wrap_content"                
                android:layout_gravity="top"
                android:layout_weight="1" />
        </LinearLayout>
        <WebView 
            android:id="@+id/webview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
</LinearLayout>

而且你还可以参考Need帮助现货Android浏览器切换到的WebView 看到,如果你正确地启动URL。

And you can also refer to the Need help changing from stock android browser to webview to see if you are launching the url correctly.