I'm also noticing that in my layout that I inflate inside the ListView, if I include a CheckBox, the behavior for the onClick for the ListView isn't working, meaning, usually when you click/touch the item in the ListView, it will be highlighted or change colors. When I add a CheckBox, it doesn't highlight anymore and my onListItemClick(...) listener never gets called. Is there a bug? or a trick to getting this to work? If it matters, my layout is a RelativeLayout(also tried with LinearLayout), with a CheckBox on the far left, then a TwoLineListItem and finally an ImageView. If I just remove the CheckBox, it will respond how a ListView normally should respond but once I include the CheckBox it won't behave normally as described above.
On May 18, 1:14 pm, Wall-E <[email protected]> wrote: > So I have a listview using an arrayadapter. I want to detect a > horizontal swipe/fling to toggle a view item to gone/visible inside > the listview. What I've done to achieve this is to have a > SimpleGestureDetector to detect the fling. I've added an > onTouchListener to the listview that returns if a fling/swipe was > detected. If a swipe was detected, I set that view to either visible > or gone. Now this works for the first item in my listview but not for > the others. Inside of the onTouch method I have access to a View in > which I access my layout items. Also, the listview gets distorted and > does not refresh correctly. I even call invalidate on the listview > after I've done the change. So first off, am I going about this > correctly or is there a better/proper method to accomplish what I'm > trying to do? > > Here is some of my code: > > gestureListener = new View.OnTouchListener() > { > public boolean onTouch(View v, MotionEvent event) > { > if(gestureDetector.onTouchEvent(event)) > { > ImageView deleteImageView = (ImageView) > v.findViewById(R.id.deleteSourceImageView); > if(deleteImageView.getVisibility() == View.GONE) > { > deleteImageView.setVisibility(View.VISIBLE); > } > else > { > deleteImageView.setVisibility(View.GONE); > } > dataListView.invalidate(); > return true; > } > return false; > } > }; > > class MyGestureDetector extends SimpleOnGestureListener > { > @Override > public boolean onFling(MotionEvent e1, MotionEvent e2, float > velocityX, float velocityY) > { > try > { > if (Math.abs(e1.getY() - e2.getY()) > > SWIPE_MAX_OFF_PATH) > { > return false; > } > // right to left swipe > if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && > Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) > { > return true; > } > else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && > Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) > { > return true; > } > } > catch (Exception e) > { > // nothing > return false; > } > return false; > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

