Currently I am working on a fragment that simply a webview with framelayout, the problem is, I would like to do something like the pull down refresh ( just like some refresh function common of list view ).
Assume there is a refreshToDo()
function , all I need is just a layout (when I drag the body it show the refresh header, when the header at the certain height, it call refreshToDo()
, when I release it , it go back to top and hide) , but how to implement that? thanks
layout: (It contains the main content and target content, you can simply ingore target content, it is for playing the video in fullscreen in webview):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<FrameLayout
android:id="@+id/target_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:visibility="gone" >
</FrameLayout>
</RelativeLayout>
Fragment:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.web_fragment, container,
false);
mTargetView = (FrameLayout) rootView.findViewById(R.id.target_view);
mContentView = (FrameLayout) rootView.findViewById(R.id.main_content);
mWebView = (WebView) rootView.findViewById(R.id.webView);
mWebView.setVerticalScrollBarEnabled(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
mWebView.setWebViewClient(new MyWebViewClient(getActivity()));
mWebView.setWebChromeClient(new MyWebChromeClient(getActivity()));
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(this, "jsinterface");
// default go to video page
mWebView.loadUrl("file://" + getActivity().getFilesDir().toString()
+ StorageUtils.finalfoldername.toString() + "video_list.html");
return rootView;
}
How to add the custom view to implement the pull down refresh? Thanks