I'm using the setOnTouchlistner class for detecting left and right swipes. I can get it to work fine on a listview, but the listview is too small to get a good swipe every time.
I then tried to set the swipe to the main LinearLayout. I have three other LinearLayout inside this. But it is not working thanks for any help.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:orientation="horizontal"
android:id="@+id/driveView"
android:focusableInTouchMode="true"
android:focusable="true"
android:clickable="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
Here is the code:
private LinearLayout myView = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.drive);
myView = (LinearLayout)findViewById(R.id.driveView);
myView.setOnTouchListener(new OnSwipeTouchListener(mContext) {
@Override
public void onSwipeLeft() {
showdrivedialog(mContext, "Drive List", "Change to Ascending list!");
}
public void onSwipeRight() {
showdrivedialog(mContext, "Drive List", "Change to Descending list!");
}
});