Go Back   Android Forums > Android Development > Application Development
Application Development Dev Lounge for the Coder Folks
Gamers - Check out our new sister sites!
Nintendo Wii U!    |    OUYA - $99 Android System!

test: Reply
 
LinkBack Thread Tools
Old April 26th, 2012, 10:32 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Feb 2012
Posts: 7
 
Device(s): acer tab
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Question swipe not working for webview

My layout xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="#ffffff">


    <RelativeLayout android:id="@+id/l1"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:background="@drawable/blank_header" 
        android:layout_height="60dip">
        <Button android:id="@+id/home" android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical|center_horizontal"
            android:layout_width="wrap_content" android:layout_marginLeft="3dip"
            android:minHeight="20dip" android:layout_marginTop="0dip"
            android:minWidth="30dip" android:background="@drawable/btn_back">
        </Button>
        <LinearLayout android:layout_height="wrap_content"
            android:gravity="center" android:layout_width="fill_parent"
            android:layout_centerVertical="true" android:layout_marginRight="80dip"
            android:weightSum="1">
            <TextView android:layout_marginTop="5dip"
                android:layout_marginLeft="215dip" android:text="Epub Reader"
                android:mar*****epeatLimit="marquee_forever" android:textSize="15dip"
                android:layout_gravity="left" android:layout_width="fill_parent"
                android:id="@+id/txt_chaptertitle" android:ellipsize="marquee"
                android:singleLine="false" android:layout_height="wrap_content"
                android:typeface="serif" android:textStyle="bold"
                android:layout_weight="0.18"></TextView>
        </LinearLayout>
    </RelativeLayout>
    <LinearLayout android:id="@+id/l2" android:layout_below="@id/l1"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:gravity="right" android:background="#ffffff"
        android:layout_height="wrap_content">


        <TextView android:textSize="15dip" android:id="@+id/txt_pageCount"
            android:layout_height="30dip" android:layout_width="70dip"
            android:layout_gravity="bottom|right|center_horizontal"
            android:paddingTop="5dip"></TextView>
        </LinearLayout>

        <LinearLayout
    android:layout_below="@id/l2"
        android:layout_above="@id/l3"        android:orientation="vertical" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="#ffffff">
            <WebView android:id="@+id/webView3" android:layout_height="fill_parent"
                android:layout_width="fill_parent">
            </WebView>
        </LinearLayout>

    <RelativeLayout android:layout_height="70dip" android:gravity="center" android:layout_width="fill_parent" android:id="@+id/l3" android:background="@drawable/footer" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true">
        <Button  android:layout_height="wrap_content" android:background="@drawable/btnnext" android:id="@+id/button4" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_alignParentRight="true"></Button >
        <Button  android:layout_height="wrap_content" android:background="@drawable/btnprevious" android:id="@+id/button3" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_alignParentLeft="true"></Button >
    
    </RelativeLayout>
</RelativeLayout>
I am having webview inside linear layout which in turn inside two relative layouts and the code to detect swipe is

Code:
public class Reader{

  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

 gestureDetector=new GestureDetector(new MyGestureDetector());

}

  class MyGestureDetector extends SimpleOnGestureListener implements OnGestureListener{
      @Override
      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) {  // left swipe
                  
                  if(isLandscape()){
                      if(isnextButton){
                          forward();
                          
                      }} 
                      else{
                      if(isnextButtonPot){
                          forwardPotrait();
                      }
                      }
                        
                  
                  
                  
                  
              }  
              else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {  // right swipe
                 
                  
                     if(isLandscape()){
                      if(ispreviousButton){
                          previous();
                      }}
                      else{
                          
                          if(ispreviousButtonPot){
                              previousPotrait();
                          }
                          
                          
                      }
                  
                  
                  
              }
          } 
          
          
          catch (Exception e) {
              // nothing
          }
          return false;
      }
  }
      

}
My problem is when i swipe left to right or right to left
onfling method it is not getting called.I have pulled my hair for whole day so can any one help in this issue.


natarajan1986 is offline  
Reply With Quote
Sponsors
Reply
Tags
android, swipe control, webview


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:01 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.