【问题标题】:Android - Webview as list view footer not workingAndroid - Webview 作为列表视图页脚不起作用
【发布时间】:2014-02-26 22:31:58
【问题描述】:

我正在尝试将 Web 视图显示为列表视图的页脚。

将脚本添加到 html 文件并放置在 assets 文件夹中 使用 Web 视图创建布局 将网页视图作为页脚放置,但我看不到网页视图

WebView 布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

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

assets文件夹中的html文件:

<html>
<body>
<div id="ym_1234" class="ym"></div>
<script type="text/javascript">(function(e,t){if(t._ym===void 0){t._ym="";var m=e.createElement("script");
m.type="text/javascript",m.async=!0,m.src="//static.yieldmo.com/ym.min.js",(e.getElementsByTagName("head")[0]||e.getElementsByTagName("body")[0]).appendChild(m)}else t._ym instanceof String||void 0===t._ym.chkPls||t._ym.chkPls()})(document,window);
</script>
</body>
</html>

我添加页脚的片段代码:

ListView list = (ListView)view.findViewById(android.R.id.list);
WebView web;
        LayoutInflater inflaterOf = getActivity().getLayoutInflater();

        LinearLayout listFooterView = (LinearLayout)inflaterOf.inflate(com.philly.prosportsframework.R.layout.list_with_footer, null);
        web = (WebView)listFooterView.findViewById(R.id.webview_footer);
        web.getSettings().setJavaScriptEnabled(true);
        web.setWebViewClient(new WebViewClient());
        web.loadUrl("file:///android_asset/news_footer.html");

        list.addFooterView(listFooterView);

我只能看到列表,但看不到页脚中的 web 视图

【问题讨论】:

    标签: android html android-listview android-webview


    【解决方案1】:

    一个简单的问题....你在设置适配器之前添加页脚吗?

    list.addFooterView(listFooterView);
    list.setAdapter(adapter);
    

    无法从您的代码中读取...

    【讨论】:

    • 我尝试将文本视图设置为页脚并且它有效,我能够看到它。然后我将 textview 布局的位置更改为 web 视图布局。我只粘贴了添加页脚的代码
    • ok ...所以我创建了一个简单的应用程序,看看它是否可以在页脚中显示 webview 并发现它是...也尝试使用 View 而不是线性布局.. . 如果它不起作用然后尝试使用 void addFooterView(View v, Object data, boolean isSelectable)
    猜你喜欢
    • 1970-01-01
    • 2013-10-09
    • 2015-10-19
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多