ListView, onFling(horizontal), gesture issues

by Wall-E » Thu, 19 May 2011 02:50:58 GMT

Sponsored Links
 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)
                        ImageView deleteImageView = (ImageView)
                        if(deleteImageView.getVisibility() == View.GONE)
                    return true;
                return false;

        class MyGestureDetector extends SimpleOnGestureListener
            public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY)
                if (Math.abs(e1.getY() - e2.getY()) >
                    return false;
                // right to left swipe
                if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE &&
                        return true;
                else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE &&
                        return true;
                catch (Exception e)
                // nothing
                        return false;
                return false;


Re: ListView, onFling(horizontal), gesture issues

by Wall-E » Thu, 19 May 2011 06:07:06 GMT

 '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:14pm, Wall-E <> wrote:


Sponsored Links

Other Threads

1. GPS reading jumps a thousand miles or more

my android app that is a location listener gets fairly good data but
once in a while the location jumps by a thousand miles or more and
stays there for numerous updates with no corresponding major increase
in the (in)accuracy reading.

for example you can see that at 3:07 and 3:09  and 3:10 i was in
portland oregon with less than 1024 meters of accuracy. at 3:48 i get
consistent readings in the pacific ocean, with a supposed accuracy of
less than 1024 meters in the first two readings.

donpG1  2008-12-17 03:57:59 UTC         53.5545998811722        
donpG1  2008-12-17 03:55:58 UTC         53.5575771331787        
donpG1  2008-12-17 03:53:58 UTC         53.5582852363586        -135.15274643898
donpG1  2008-12-17 03:51:59 UTC         53.5593849420547        -135.15048801899
donpG1  2008-12-17 03:49:58 UTC         53.5648941993713        
donpG1  2008-12-17 03:48:49 UTC         53.5753923654556        
donpG1  2008-12-17 03:10:36 UTC         45.5137449502945        
donpG1  2008-12-17 03:09:02 UTC         45.5137234926224        
donpG1  2008-12-17 03:07:01 UTC         45.5135464668274        

whats odd is that the location is not a random reading but consistent
readings in the same wildly inaccurate place. its almost like the G1
starts playing a debugging kml file buried deep in the the GPS code.


2. Porting to DaVinci EVM


I want to know if any of you guys have already ported Android to
DaVinci EVM ( I have the 6446 ) successfully. I happened to port the
m5 version months ago, and now I an going to port the 1.0 version.

Could I still use the 2.6.23 kernel on the board or do I need to
upgrade it to 2.6.25 ? If not, did you happen to create a patch? I
used the Benno's patch for m5, and not very familiar with patching,
diff .... If someone could hint me how to create a new patch it would
be great.

I'll keep updating my progress here.

unsubscribe: [EMAIL PROTECTED]

3. Installation on HTC Wizard

4. need clarification on resolving intents.

5. Starting new group for Android OpenMax

6. Job Openings in Northern Virginia for Android Developers

7. "Kernel panic - not syncing: No init found. Try passing init= option to kernel."