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)
            {
                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;
            }



-- 



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 <bashee...@gmail.com> 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        
-135.155128240585
6144.0
donpG1  2008-12-17 03:55:58 UTC         53.5575771331787        
-135.154876112938
4096.0
donpG1  2008-12-17 03:53:58 UTC         53.5582852363586        -135.15274643898
3072.0
donpG1  2008-12-17 03:51:59 UTC         53.5593849420547        -135.15048801899
2048.0
donpG1  2008-12-17 03:49:58 UTC         53.5648941993713        
-135.139072537422
1024.0
donpG1  2008-12-17 03:48:49 UTC         53.5753923654556        
-135.129395127296
768.0
donpG1  2008-12-17 03:10:36 UTC         45.5137449502945        
-122.627688646317
512.0
donpG1  2008-12-17 03:09:02 UTC         45.5137234926224        
-122.627495527267
512.0
donpG1  2008-12-17 03:07:01 UTC         45.5135464668274        
-122.627694010735
1024.0

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.

don
--~--~---------~--~----~------------~-------~--~----~

2. Porting to DaVinci EVM

Hi,

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.

Regards,
Francois
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [EMAIL PROTECTED]
website: 

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."