2015-04-07 35 views
2

我正在做一个翻转卡应用程序,其中我在框架布局上应用了onTouchListener。通过使用singletap gesturelistener我是从前向后翻牌,反之亦然。每件事情都很好。由于我的数据很大,我必须在我的虚拟布局中引入滚动视图。在framelayout上触摸侦听器并在充气布局问题上滚动查看

setContentView(R.layout.flashframe); 
cardView = (FrameLayout)findViewById(R.id.container); 
    cardView.setOnTouchListener(this); 
    mGestureDetector=new GestureDetector(this.getBaseContext(), new MyGestureListener(this)); 
    if(savedInstanceState==null){ 
     getFragmentManager().beginTransaction() 
       .add(R.id.container, new CardFrontFragment()).commit(); 
     cardNumber=1; 
     setCard(cardNumber); 
    } 
@Override 
public boolean onTouch(View v, MotionEvent event) { 
    // TODO Auto-generated method stub 
    mGestureDetector.onTouchEvent(event); 
    return true; 
} 
public class MyGestureListener extends GestureDetector.SimpleOnGestureListener { 
    public MyGestureListener(OpenClass openClass) { 
     // TODO Auto-generated constructor stub 
    } 
      @Override 
    public boolean onSingleTapUp(MotionEvent me) 
    { 
     flipCard(); 
     return true; 
    } 
    } 

XML布局: -

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:weightSum="100" android:layout_height="match_parent"> 
    <ScrollView android:layout_weight="30" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TextView android:text="To be retrieved from sqlite" 
      android:layout_width="match_parent"  android:layout_height="match_parent"></TextView> 
     </ScrollView> 
</LinearLayout> 

框架布局: -

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" /> 

当我夸大我的滚动视图布局,手势听者没有响应,而滚动视图工作前卡。我无法翻转,如果我使用滚动视图。

请帮助我,我怎么能解决这个..

+0

发布您的布局xml – CAS

+0

@Chadi Abou Sleiman - 我发布了我的XML布局。 – nani

+0

你的框架布局在哪里? – CAS

回答

0

您应该重写了滚动的onTouchListener。在它你可以检查每当翻转你的卡或滚动...

+0

可以请你解释一下如何用示例覆盖ontouchlistener ... – nani

+0

这里是一个例子:http://techin-android.blogspot.in/2011/11/swipe-event-in-android-scrollview.html –