2015-04-07 23 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 –