Friday, May 17, 2013

[android help] Android - Which layout to listen to implement gestures in my application


I want my application to listen to gesture. Just a simple gesture l-r, r-l. So, from the main layout, when you swipe from left to right, a sidemenu appears. And when you swipe from right to left, side menu hides. But what i did was, I let sideMenu listen for the ontouch, so when the sidemenu is hidden, I can't show it by just swiping the mainlayout. But i managed to hide that sidemenu after it was shown because i tried to show it first.


So, i tried to listen from my multiColumnListView. It worked but now I can't scroll my multiColumnListView. Also, the problem with placing the listener in the multiColumnListView, when there's is no content, no one will listen the gesture.


enter image description here


The red, orange and maroon boxes are my headers and footers. The multiColumnListView is the broken yellow green box. Then the contents are the green boxes. Then the right image is when there is no content. This is my current layout:



xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ignoreGravity="@+id/sideMenu"
android:id="@+id/mainRelativeLayout">

android:id="@+id/frameLayout"
android:layout_below="@+id/header_1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

android:id="@+id/search_header"
layout="@layout/search_header" />

xmlns:pla="http://schemas.android.com/apk/res-auto"
android:id="@+id/multiColumnListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >


android:id="@+id/sideMenu" />



android:id="@+id/header_1"
android:layout_alignParentTop="true"
layout="@layout/header_1"/>




I tried listening from my RelativeLayout. Though it work but when there are contents, i should start the gesture from the left most part.



final GestureDetector gdt = new GestureDetector(this,new GestureListener());
sideMenu.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
gdt.onTouchEvent(event);
return true;
}
});

final GestureDetector gest = new GestureDetector(this,new GestureListener());
mainLayout.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(final View v, final MotionEvent event) {
gest.onTouchEvent(event);
return true;
}
});


This is how i listen. I listen from my relativelayout and sidemenu. But I want also to listen from the center of my application eventhough there are contents(multicolumnlistview).


How can i listen from multicolumnlistview without ruining its scroll? Or are there other ways to listen for gestures? Any ideas? Help is greatly appreciated.



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...