gpt4 book ai didi

android - WebView 成 fragment (android.support.v4)

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:41:49 30 4
gpt4 key购买 nike

我使用 ViewPager 获得了一个选项卡菜单。每个选项卡都包含来自 android.support.v4 包的 fragment (与旧 SDK 的兼容性)。其中一个 fragment 是 WebView(称为 FragmentWeb),我希望它保留在寻呼机布局中。问题是当我的 WebView 膨胀时,它以全屏模式运行。

有没有办法让网络浏览器一直在我的选项卡下?

谢谢

我的 fragment 类:FragmentWeb.java

public class FragmentWeb extends Fragment {

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View mainView = (View) inflater.inflate(R.layout.fragment_web, container, false);
WebView webView = (WebView) mainView.findViewById(R.id.webview);
webView.loadUrl("http://www.google.com");
return mainView;
}
}

我的 Fragment 的布局:fragment_web.xml

<?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" >

<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

</LinearLayout>

最佳答案

您可以通过替换以下内容来简单地调整 WebViewFragment 的当前实现以满足您的需求:

import android.app.Fragment;

通过

import android.support.v4.app.Fragment;

在您自己的 WebViewFragment.java 副本中来源。

关于android - WebView 成 fragment (android.support.v4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9279632/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com