Hi all, I am using a Gallery view. This is my goal: I would like to be able to listen for gestures so that I can take specifc action, in addition to allowing the "usual" action that the Android framework provides. For instance, when the user scrolls the Gallery, I would like to know that the user has moved away from the currently selected item to go to a new item, but I also don't want to interfere with the Gallery scrolling action (Gallery.onScroll()).
If instead of a Gallery view, I had a LinearLayout, this would be easy, as my Activity could implement OnGestureListener, I could instantiate a GestureDetector variable which is "fed" to onTouch(), and then override the onScroll() method. (see http://groups.google.com/group/android-developers/browse_thread/thread/59dbe46cfbc5672f/327fcc495ba1f9a5?hide_quotes=no) 1) But gallery view already provides many (if not all) of the gesture listener methods (onTouch(), onScroll(), onDown() etc.). So can I override the onScroll() method in the Gallery class? I am not very experienced, but this seems to be possible only if I create my own MyGallery.java class by extending the Gallery class and then override the onScroll() (etc) methods. But when I do that, I cannot figure out how to create my Gallery view from XML. Currently, my Gallery view is created as: public Gallery mGallery; ...(later)... mGallery = (Gallery) findViewById(R.id.gallery); I cannot simply use: public MyGallery mGallery; ...(later)... mGallery = (MyGallery) findViewById(R.id.gallery); This results in a CastException error (as you would expect). And my Layout XML file will not allow me to specify <MyGallery> instead of <Gallery> - also causing an error. Am I missing something here that could get this to work? 2) OK, the other option is to ignore the gesture listener methods provided by the Gallery class, and simply implement the OnGestureListener interface (like if I was using a view with a LinearLayout). But when I do this, the GestureDetector is not reliably activated by gestures. Sometimes it works, and sometimes it doesn't. My best guess is that sometimes the Gallery class gesture methods are being invoked instead of the the OnGestureListener interface methods. I say this because if I take my "valid" code (I say "valid" meaning that it does not cause any errors, but it is not "correct" because it does not function properly, i.e. the gesture detection is unreliable), and simply fail to instantiate my GestureDetector variable (i.e. "comment out" my GestureDetector variable like: //GestureDetector gd = new GestureDetector(this);) , then only sometimes will I get a null pointer exception. Presumeably, when I don't get a null pointer exception it is because the application is interpreting the gesture as a Gallery gesture and using the Gallery class methods on it, instead of the OnGestureListener methods. Is there a way for me to make sure that the OnGestureListener methods are always invoked instead of the Gallery methods? thanks for any guidance, Jim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---