package com.jiuqi.ui.widget; import com.jqyd.uilib.R; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.webkit.WebView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.AbsoluteLayout.LayoutParams; /** * 等待界面的WebView * * @author malingya * */ public class WaitPageWebView extends WebView { private LinearLayout waitlayout; Context context; public WaitPageWebView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.waitpage, null); waitlayout = (LinearLayout) layout.findViewById(R.id.waitlayout); ProgressBar pBar = (ProgressBar) layout.findViewById(R.id.progressBar); LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 0, 0); addView(layout, layoutParams); setWebChromeClient(new WebChromeClient()); // gd = new GestureDetector(context, sogl); } public class WebChromeClient extends android.webkit.WebChromeClient { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { waitlayout.setVisibility(GONE); } else { if (waitlayout.getVisibility() == GONE) waitlayout.setVisibility(VISIBLE); } super.onProgressChanged(view, newProgress); } } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { LayoutParams lp = (LayoutParams) waitlayout.getLayoutParams(); lp.x = l; lp.y = t; waitlayout.setLayoutParams(lp); super.onScrollChanged(l, t, oldl, oldt); } }