Swipe Gesture over TextView in ListView

Put your problem here if it does not fit any of the other categories.

Swipe Gesture over TextView in ListView

Postby tsemann » Thu Mar 03, 2011 3:16 am

Hi all,

i have a problem concerning the swipe gesture detection. I already implemented an OnGestureDetector and show you some code snippets which may help you to see an error and understand my problem. This is the implementation of my swipe gesture above the ListView. The ListView is again built by another ListAdapter. This is the ListView Implementation.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class ContentView extends Activity implements OnGestureListener {
  2. ...
  3. ...
  4.                 lv1.setAdapter(new ContentListAdapter(this, contentEnums,flyerBean,gestureScanner));
  5.                 lv1.setOnTouchListener(new OnTouchListener() {
  6.                         @Override
  7.                         public boolean onTouch(View v, MotionEvent event) {
  8.                                 return gestureScanner.onTouchEvent(event);
  9.                         }
  10.                 });
  11. ....
  12.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Now do I have to implement an OnGestureDetector in my ListAdapter for each TextView element? I already did this. But now it is the problem that my app doesn't listen to normal touches which are meant to select one of the ListView items. This is how it looks like in my ListAdapter:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 TextView tv = new TextView(context);
  2.                 ImageView image = new ImageView(context);
  3.                 image.setImageResource(contentEnum.get(arg0).getResourceId());
  4.                 // Handler Title
  5.                 tv.setTextSize(20);
  6.                 tv.setPadding(10, 5, 0, 0);
  7.                 tv.setTextSize(22);
  8.                 tv.setHeight(53);
  9.                 // specific attributes, set thumb
  10.                 container.setPadding(5, 5, 0, 0);
  11.                 tv.setOnTouchListener(new OnTouchListener() {
  12.                         @Override
  13.                         public boolean onTouch(View v, MotionEvent event) {
  14.                                 return gestureScanner.onTouchEvent(event);
  15.                         }
  16.                 });
  17.                 image.setOnTouchListener(new OnTouchListener() {
  18.                         @Override
  19.                         public boolean onTouch(View v, MotionEvent event) {
  20.                                 return gestureScanner.onTouchEvent(event);
  21.                         }
  22.                 });
  23.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

Does someone know why the app suddenly doesn't listen to normal touches on the items of the ListView anymore or have any other solution to solve this problem of detected gestures over ListView-elements?

Best regards and thank you,
tsemann
tsemann
Freshman
Freshman
 
Posts: 9
Joined: Thu Jan 13, 2011 8:19 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests