• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to detect the click event and the swipe event differently

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have an android app which contain view pager.I need to identify click event and the swipe event differently.I already overrides the onInterceptTouchEvent.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this was my problem I'd leave onInterceptTouchEvent alone and handle different events with different listeners, in this case View.OnClickListener and ViewPager.OnPageChangeListener.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a viewpager with images.I need to do something when i click images.I implement the onclick listener for view






but the when i click on the image it doesn't work the onclick listener?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why aren't you attaching the OnClickListener to the ImageView if it's clicks on the image that you're actually interested in?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I need to call another activity when i click the image.But it is unable to call another activity inside this?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does it matter what you do in a listener for where you attach it?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because i get the image in adapter,i added the onclickListener inside the adapter.but i am unable to call the another activity via intent.is there any other way to do this ulf ?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ulf ,i attached the listener to image.Is there any other way to do this ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you ask?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to call another activity when i click on the image.I have posted the my code above.But i am unable to call the activity via intent inside instantiateItem in adapter.Is there anything wrong in my code or any other place to call activity ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

because i get the image in adapter,i added the onclickListener inside the adapter.but i am unable to call the another activity via intent.is there any other way to do this ulf ?


This reasoning is fundamentally flawed. You assume because something you implemented didn't work it was the wrong way to implement it. Pardon me for being frank, but given the history of your Android development efforts as documented by your posts here, your first assumption should be that you made a mistake somewhere.

I need to call another activity when i click on the image.I have posted the my code above.But i am unable to call the activity via intent inside instantiateItem in adapter.Is there anything wrong in my code or any other place to call activity ?


What you posted doesn't even compile. If there are problems -as I've told you many times before, but unfortunately you insist on ignoring it, which is getting extremely tiresome- you need to tell us what you are doing, what you expected to happen in response, and what is actually happening. Post the values of all involved variables, the stack trace of all exceptions if there are any, etc. etc.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that is not compiling.I need to call another activity when i click the images.I am unable to call the activity inside the above call.Its not compiling.

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you don't mention it, I assume that you agree now that the kind of listener is irrelevant?

As I said, if there are error messages, post them. This latest code doesn't even try to start to start an activity, so it is even less clear than before what "I am unable to call the activity" means.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok ulf.If this is not the correct approach,what kind of approach is good.I found that using interface w can call activity method.Is it suit for this one?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm giving up, as this is getting too frustrating. You seem to be paying no attention whatsoever to what you are being told. Good luck.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the answer.We can use activity reference inside to call Intent.Below is the code



 
Seriously? That's what you're going with? I prefer this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic