【发布时间】:2015-04-07 08:54:21
【问题描述】:
我正在做一个翻转卡片应用程序,其中我在我的框架布局上应用了 onTouchListener。通过使用单点手势监听器,我可以从前到后翻转卡片,反之亦然。每件事都运行良好。由于我的数据很大,我必须在我的膨胀布局上引入滚动视图。
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" />
当我使用滚动视图扩展布局时,手势侦听器没有响应,而滚动视图正在前卡上工作。如果我使用滚动视图,我无法翻转。
请帮帮我,我该如何解决这个问题..
【问题讨论】:
-
发布您的布局 xml
-
@Chadi Abou Sleiman--我已经发布了我的 xml 布局。
-
你的框架布局在哪里??
-
@Chadi Abou Sleiman--发布
-
哪个是完整的
R.layout.flashframexml?
标签: android scrollview ontouchlistener android-framelayout gestures