Android - Webview as list view footer not working

不打扰是莪最后的温柔 提交于 2019-12-25 12:24:10

问题


I am trying to display web view as the footer for the list view.

Added the script to the html file and placed in assets folder Created a layout with web view Placed the web view as footer but I am not able to see the web view

WebView layout:

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

html file in assests folder:

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

Fragment code where I added the footer:

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);

I am only able to see the list but the the web view in the footer is not seen


回答1:


one quick question .... are u adding footer before setting up the adapter ?

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

it cant be read from your code ...



来源:https://stackoverflow.com/questions/22054913/android-webview-as-list-view-footer-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!