2010-07-10 43 views
2

我試圖從列表視圖滑動....從左到右滑動Web視圖。我按照顯示here的方式。無法刷卡webview?

而且我已經設置在viewflipper

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/flipper" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout> 
     <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/webview1" android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
     <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/webview2" android:layout_width="fill_parent" 
      android:layout_height="fill_parent" /> 
    </LinearLayout> 

webviews但我認爲web視圖的onTouchEvent不在這裏工作了。

@Override 
    public boolean onTouchEvent(MotionEvent event) { 
     if (gestureDetector.onTouchEvent(event)) 
      return true; 
     else 
      return false; 
    } 

回答

1

嘗試將兩個WebView移出LinearLayout。 ViewFlipper在其子項之間切換,並且使用您的設置,ViewFlipper只有一個子項。試試這個:

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/flipper" android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
    <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webview1" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 
    <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webview2" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 
</ViewFlipper>