0
我有一個自定義的WebView佈局如下問題+安卓
class MyWebView extends WebView {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
Context context;
GestureDetector gd;
public myWebView(Context context) {
super(context);
this.context = context;
gd = new GestureDetector(context, sogl);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return gd.onTouchEvent(event);
}
GestureDetector.SimpleOnGestureListener sogl = new GestureDetector.SimpleOnGestureListener() {
public boolean onDown(MotionEvent event) {
return true;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return false;
// right to left swipe
if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
// mScrollwidth=mScrollwidth+mWebView.getWidth();
// mWebView.scrollTo(mScrollwidth,0);
//System.out.println(mScrollwidth);
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
// mScrollwidth=mWebView.getWidth();
// mWebView.scrollTo((mScrollwidth-mWebView.getWidth()),0);
}
} catch (Exception e) {
// nothing
}
return false;
}
};
}
和我如下與圖像視圖進行合併,
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:MyWebView="http://schemas.android.com/apk/res/com.mireader.mywebview">
<ImageView
android:layout_width="120px"
android:layout_height="110px"
android:scaleType="center"
android:src="@drawable/d" />
<com.mireader.mywebview.MyWebView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</merge>
我收到提示在運行時如下,
java.lang.RuntimeException:無法啓動活動ComponentInfo {com.mireader/com.mireader.demoweb}:android.view.InflateException:二進制XML文件行#11:錯誤的類com.mireader.mywebview .MyWebView
@ Tox1c謝謝...ü讓我很快樂:) – vnshetty 2011-03-23 11:19:03