I have used single page on which data is loaded again and again.
A same page is being used for loading data; ie headline, photo and description. Can you help me so that I can apply swipe function in it? I am building an application like Pulse News check it on the swipe function. I have built it in phonegap, HTML5, CSS3 and JavaScript and also jQuery mobile.
I know how to to swipe the pages, where are more than one page but there is only one page on which data is loaded dynamically and only the content is changed, so how should I add swipe to it so that it works on iPhone and Android?
It doesn't matter how many pages you have in your app. You need to detect SWIPE action in your activity and reload data instead of really swiping pages. to do that: in your touch event listener, detect:
ACTION_MOVE
like this:
if(event.getAction() != MotionEvent.ACTION_MOVE)
even check the distance to make sure a SWIPE happened:
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN:
if(isDown == false)
{
startX = event.getX();
startY = event.getY();
isDown = true;
}
Break;
case MotionEvent.ACTION_UP
{
endX = event.getX();
endY = event.getY();
break;
}
}
calculate the distance then, if sounds like more than a click... consider it a swipe and reload your data good luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With