Search Results

Search found 10 results on 1 pages for 'gesturedetector'.

Page 1/1 | 1 

  • Trouble with detecting gestures over ListView

    - by Andrew
    I have an Activity that contains a ViewFlipper. The ViewFlipper includes 2 layouts, both of which are essentially just ListViews. So the idea here is that I have two lists and to navigate from one to the other I would use a horizontal swipe. I have that working. However, what ever list item your finger is on when the swipe begins executing, that item will also be long-clicked. Here is the relevant code I have: public class MyActivity extends Activity implements OnItemClickListener, OnClickListener { private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; private GestureDetector mGestureDetector; View.OnTouchListener mGestureListener; 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) { if (mCurrentScreen != SCREEN_SECONDLIST) { mCurrentScreen = SCREEN_SECONDLIST; mFlipper.setInAnimation(inFromRightAnimation()); mFlipper.setOutAnimation(outToLeftAnimation()); mFlipper.showNext(); updateNavigationBar(); } } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentScreen != SCREEN_FIRSTLIST) { mCurrentScreen = SCREEN_FIRSTLIST; mFlipper.setInAnimation(inFromLeftAnimation()); mFlipper.setOutAnimation(outToRightAnimation()); mFlipper.showPrevious(); updateNavigationBar(); } } } catch (Exception e) { // nothing } return true; } } @Override public boolean onTouchEvent(MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) return true; else return false; } ViewFlipper mFlipper; private int mCurrentScreen = SCREEN_FIRSTLIST; private ListView mList1; private ListView mList2; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.layout_flipper); mFlipper = (ViewFlipper) findViewById(R.id.flipper); mGestureDetector = new GestureDetector(new MyGestureDetector()); mGestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) { return true; } return false; } }; // set up List1 screen mList1List = (ListView)findViewById(R.id.list1); mList1List.setOnItemClickListener(this); mList1List.setOnTouchListener(mGestureListener); // set up List2 screen mList2List = (ListView)findViewById(R.id.list2); mList2List.setOnItemClickListener(this); mList2List.setOnTouchListener(mGestureListener); } … } If I change the "return true;" statement from the GestureDetector to "return false;", I do not get long-clicks. Unfortunately, I get regular clicks. Does anyone know how I can get around this?

    Read the article

  • Trying to implement fling events on an object

    - by Adam Short
    I have a game object, well a bitmap, which I'd like to "fling". I'm struggling to get it to fling ontouchlistener due to it being a bitmap and not sure how to proceed and I'm struggling to find the resources to help. Here's my code so far: https://github.com/addrum/Shapes GameActivity class: package com.main.shapes; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View.OnTouchListener; import android.view.Window; public class GameActivity extends Activity { private GestureDetector gestureDetector; View view; Bitmap ball; float x, y; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Remove title bar this.requestWindowFeature(Window.FEATURE_NO_TITLE); view = new View(this); ball = BitmapFactory.decodeResource(getResources(), R.drawable.ball); gestureDetector = new GestureDetector(this, new GestureListener()); x = 0; y = 0; setContentView(view); ball.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(android.view.View v, MotionEvent event) { // TODO Auto-generated method stub return false; } }); } @Override protected void onPause() { super.onPause(); view.pause(); } @Override protected void onResume() { super.onResume(); view.resume(); } public class View extends SurfaceView implements Runnable { Thread thread = null; SurfaceHolder holder; boolean canRun = false; public View(Context context) { super(context); holder = getHolder(); } public void run() { while (canRun) { if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); c.drawARGB(255, 255, 255, 255); c.drawBitmap(ball, x - (ball.getWidth() / 2), y - (ball.getHeight() / 2), null); holder.unlockCanvasAndPost(c); } } public void pause() { canRun = false; while (true) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { canRun = true; thread = new Thread(this); thread.start(); } } } GestureListener class: package com.main.shapes; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; public class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_THRESHOLD_VELOCITY = 200; @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { //From Right to Left return true; } else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { //From Left to Right return true; } if (e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { //From Bottom to Top return true; } else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) { //From Top to Bottom return true; } return false; } @Override public boolean onDown(MotionEvent e) { //always return true since all gestures always begin with onDown and<br> //if this returns false, the framework won't try to pick up onFling for example. return true; } }

    Read the article

  • Android question - how to prep 100 images to be shown via Fling/Swipe?

    - by fooyee
    I'm totally new to this, been tinkering around for a week. Came up with a simple image viewer app for 2 images. Feature: Left and right swipes will switch the images. Dead simple. What i'd like to do: Have up to 100 images. note: All my images are in my res/drawable folder. They're named image1.png to image100.png I obviously don't want to do: ImageView i = new ImageView(this); i.setImageResource(R.drawable.image1); viewFlipper.addView(i); ImageView i2 = new ImageView(this); i2.setImageResource(R.drawable.image2); viewFlipper.addView(i2); ImageView i3 = new ImageView(this); i3.setImageResource(R.drawable.image3); viewFlipper.addView(i3); all the way to i100. how do I make this into a loop, which is flexible and reads everything from the drawable folder ( and not be limited to 100 images)? source: public class ImageViewTest extends Activity { private static final String LOGID = "CHECKTHISOUT"; private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; private GestureDetector gestureDetector; View.OnTouchListener gestureListener; private Animation slideLeftIn; private Animation slideLeftOut; private Animation slideRightIn; private Animation slideRightOut; private ViewFlipper viewFlipper; String message = "Initial Message"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Set up viewflipper viewFlipper = new ViewFlipper(this); ImageView i = new ImageView(this); i.setImageResource(R.drawable.sample_1); ImageView i2 = new ImageView(this); i2.setImageResource(R.drawable.sample_2); viewFlipper.addView(i); viewFlipper.addView(i2); //set up animations slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in); slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out); slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); slideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); //put up a brownie as a starter setContentView(viewFlipper); gestureDetector = new GestureDetector(new MyGestureDetector()); } public 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) { Log.v(LOGID,"right to left swipe detected"); viewFlipper.setInAnimation(slideLeftIn); viewFlipper.setOutAnimation(slideLeftOut); viewFlipper.showNext(); setContentView(viewFlipper); } // left to right swipe else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { Log.v(LOGID,"left to right swipe detected"); viewFlipper.setInAnimation(slideRightIn); viewFlipper.setOutAnimation(slideRightOut); viewFlipper.showPrevious(); setContentView(viewFlipper); } } catch (Exception e) { // nothing } return false; } } // This doesn't work @Override public boolean onTouchEvent(MotionEvent event) { if (gestureDetector.onTouchEvent(event)){ Log.v(LOGID,"screen touched"); return true; } else{ return false; } } }

    Read the article

  • Android - HorizontalScrollView within ScrollView Touch Handling

    - by Joel
    Hi, I have a ScrollView that surrounds my entire layout so that the entire screen is scrollable. The first element I have in this ScrollView is a HorizontalScrollView block that has features that can be scrolled through horizontally. I've added an ontouchlistener to the horizontalscrollview to handle touch events and force the view to "snap" to the closest image on the ACTION_UP event. So the effect I'm going for is like the stock android homescreen where you can scroll from one to the other and it snaps to one screen when you lift your finger. This all works great except for one problem: I need to swipe left to right almost perfectly horizontally for an ACTION_UP to ever register. If I swipe vertically in the very least (which I think many people tend to do on their phones when swiping side to side), I will receive an ACTION_CANCEL instead of an ACTION_UP. My theory is that this is because the horizontalscrollview is within a scrollview, and the scrollview is hijacking the vertical touch to allow for vertical scrolling. How can I disable the touch events for the scrollview from just within my horizontal scrollview, but still allow for normal vertical scrolling elsewhere in the scrollview? Here's a sample of my code: public class HomeFeatureLayout extends HorizontalScrollView { private ArrayList<ListItem> items = null; private GestureDetector gestureDetector; View.OnTouchListener gestureListener; private static final int SWIPE_MIN_DISTANCE = 5; private static final int SWIPE_THRESHOLD_VELOCITY = 300; private int activeFeature = 0; public HomeFeatureLayout(Context context, ArrayList<ListItem> items){ super(context); setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); setFadingEdgeLength(0); this.setHorizontalScrollBarEnabled(false); this.setVerticalScrollBarEnabled(false); LinearLayout internalWrapper = new LinearLayout(context); internalWrapper.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); internalWrapper.setOrientation(LinearLayout.HORIZONTAL); addView(internalWrapper); this.items = items; for(int i = 0; i< items.size();i++){ LinearLayout featureLayout = (LinearLayout) View.inflate(this.getContext(),R.layout.homefeature,null); TextView header = (TextView) featureLayout.findViewById(R.id.featureheader); ImageView image = (ImageView) featureLayout.findViewById(R.id.featureimage); TextView title = (TextView) featureLayout.findViewById(R.id.featuretitle); title.setTag(items.get(i).GetLinkURL()); TextView date = (TextView) featureLayout.findViewById(R.id.featuredate); header.setText("FEATURED"); Image cachedImage = new Image(this.getContext(), items.get(i).GetImageURL()); image.setImageDrawable(cachedImage.getImage()); title.setText(items.get(i).GetTitle()); date.setText(items.get(i).GetDate()); internalWrapper.addView(featureLayout); } gestureDetector = new GestureDetector(new MyGestureDetector()); setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { return true; } else if(event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL ){ int scrollX = getScrollX(); int featureWidth = getMeasuredWidth(); activeFeature = ((scrollX + (featureWidth/2))/featureWidth); int scrollTo = activeFeature*featureWidth; smoothScrollTo(scrollTo, 0); return true; } else{ return false; } } }); } class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { //right to left if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { activeFeature = (activeFeature < (items.size() - 1))? activeFeature + 1:items.size() -1; smoothScrollTo(activeFeature*getMeasuredWidth(), 0); return true; } //left to right else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { activeFeature = (activeFeature > 0)? activeFeature - 1:0; smoothScrollTo(activeFeature*getMeasuredWidth(), 0); return true; } } catch (Exception e) { // nothing } return false; } } }

    Read the article

  • Gesture Detector not firing

    - by Tyler
    So I'm trying to create a input class that implements a InputHandler & GestureListener in order to support both Android & Desktop. The problem is that not all the methods are being called properly. Here is the input class definition & a couple of the methods: public class InputHandler implements GestureListener, InputProcessor{ ... public InputHandler(OrthographicCamera camera, Map m, Player play, Vector2 maxPos) { ... @Override public boolean zoom(float originalDistance, float currentDistance) { //this.zoom = true; this.zoomRatio = originalDistance / currentDistance; cam.zoom = cam.zoom * zoomRatio; Gdx.app.log("GestureDetector", "Zoom - ratio: " + zoomRatio); return true; } @Override public boolean touchDown(int x, int y, int pointerNum, int button) { booleanConditions[TOUCH_EVENT] = true; this.inputButton = button; this.inputFingerNum = pointerNum; this.lastTouchEventLoc.set(x,y); this.currentCursorPos.set(x,y); if(pointerNum == 1) { //this.fingerOne = true; this.fOnePosition.set(x, y); } else if(pointerNum == 2) { //this.fingerTwo = true; this.fTwoPosition.set(x,y); } Gdx.app.log("GestureDetector", "touch down at " + x + ", " + y + ", pointer: " + pointerNum); return true; } The touchDown event always occurs but I can never trigger Zoom (or pan among others...). The following is where I register and create the input handler in the "Game Screen". public class GameScreen implements Screen { ... this.inputHandler = new InputHandler(this.cam, this.map, this.player, this.map.maxCamPos); Gdx.input.setInputProcessor(this.inputHandler); Anyone have any ideas why zoom, pan, etc... are not triggering? Thanks!

    Read the article

  • Android: ScrollView in flipper

    - by Manu
    I have a flipper: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/ParentLayout" xmlns:android="http://schemas.android.com/apk/res/android" style="@style/MainLayout" > <LinearLayout android:id="@+id/FlipperLayout" style="@style/FlipperLayout"> <ViewFlipper android:id="@+id/viewflipper" style="@style/ViewFlipper"> <!--adding views to ViewFlipper--> <include layout="@layout/home1" android:layout_gravity="center_horizontal" /> <include layout="@layout/home2" android:layout_gravity="center_horizontal" /> </ViewFlipper> </LinearLayout> </LinearLayout> The first layout,home1, consists of a scroll view. What should I do to distinguish between the flipping gesture and the scrolling? Presently: if I remove the scroll view, I can swipe across if I add the scroll view, I can only scroll. I saw a suggestion that I should override onInterceptTouchEvent(MotionEvent), but I do not know how to do this. My code, at this moment, looks like this: public class HomeActivity extends Activity { -- declares @Override public void onCreate(Bundle savedInstanceState) { -- declares & preliminary actions LinearLayout layout = (LinearLayout) findViewById(R.id.ParentLayout); layout.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { return true; } return false; }}); @Override public boolean onTouchEvent(MotionEvent event) { gestureDetector.onTouchEvent(event); return true; } class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ } } } Can anybody please guide me in the right direction? Thank you.

    Read the article

  • Android: how to tell if a view is scrolling

    - by Dave
    in iPhone, this would be simple---each view has a scrollViewDidScroll method. I am trying to find the equivalent in Android. My code works, but it isn't giving me what I want. I need to execute code the entire duration that a view is scrolling. So, even though I use OnGestureListener's onScroll method, it only fires when the finger is on the screen (it's not really named correctly---it should be called "onSlide" or "onSwipe", focusing on the gesture rather than the UI animation). It does not continue to fire if the user flicks the view and it is still scrolling for a few moments after the user lifts his finger. is there a method that is called at every step of the scroll? public class Scroll extends Activity implements OnGestureListener { public WebView webview; public GestureDetector gestureScanner; public int currentYPosition; public int lastYPosition; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webview = new WebView(this); setContentView(webview); webview.loadUrl("file:///android_asset/Scroll.html"); gestureScanner = new GestureDetector(this); currentYPosition = 0; lastYPosition = 0; } public boolean onTouchEvent(final MotionEvent me) { return gestureScanner.onTouchEvent(me); } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // I do stuff here. return true; }

    Read the article

  • Android onFling not responding

    - by Kevin Moore
    I am new to android first of all so think of any newbie mistakes first I am trying to add a fling function in my code. public class MainGamePanel extends SurfaceView implements SurfaceHolder.Callback, OnGestureListener { private MainThread thread; private Droid droid; private Droid droid2; private static final String TAG = gameView.class.getSimpleName(); private GestureDetector gestureScanner; public MainGamePanel(Context context){ super(context); getHolder().addCallback(this); droid = new Droid(BitmapFactory.decodeResource(getResources(), R.drawable.playerbox2), 270, 300); droid2 = new Droid(BitmapFactory.decodeResource(getResources(), R.drawable.playerbox2), 50, 300); thread = new MainThread(getHolder(), this); setFocusable(true); gestureScanner = new GestureDetector(this); } public boolean onTouchEvent(MotionEvent event){ return gestureScanner.onTouchEvent(event); } @Override protected void onDraw(Canvas canvas){ canvas.drawColor(Color.BLACK); droid.draw(canvas); droid2.draw(canvas); } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { droid.setX(50); droid.setY(50); Log.d(TAG, "Coords: x=" + e1.getX() + ",y=" + e2.getY()); return true; } @Override public boolean onDown(MotionEvent e) { droid2.setX((int)e.getX()); droid2.setY((int)e.getY()); Log.d(TAG, "Coords: x=" + e.getX() + ",y=" + e.getY()); return false; } I got the gestureListener to work with: onDown, onLongPress, and onShowPress. But i can't get any response with onFling, onSingleTapUp, and onScroll. What mistake am I making? does it have to do with views? I don't know what code would be useful to see.... so any suggestions would be much appreciated. Thank You!

    Read the article

  • Show MapView on PopupWindow

    - by Ali Nadi
    I want to show MapView on PopupWindow and get error when press-on Map. Please help! Liste.java MapView mapView; View view; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.liste); LayoutInflater mInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = mInflater.inflate(R.layout.pop_up, (ViewGroup) findViewById(R.id.popup_element), false); mapView = (MapView) view.findViewById(R.id.mapview_popup); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View v, int position, long id) { initiatePopupWindow(earthQuakeList.get(position)); } }); } private void initiatePopupWindow(EqData data) { try { mapView.setBuiltInZoomControls(true); List<Overlay> mapOverlays = mapView.getOverlays(); Drawable marker = this.getResources().getDrawable(R.drawable.marker1); HaritaOverlay itemizedoverlay = new HaritaOverlay(marker, this); Coordination coord = data.getCoordination(); GeoPoint point = new GeoPoint( (int)coord.latitude, (int)coord.longitude); OverlayItem overlayitem = new OverlayItem(point, data.lokasyon, data.name); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); Display display = getWindowManager().getDefaultDisplay(); pw = new PopupWindow(view, display.getWidth(), display.getHeight()/2, true); // display the popup in the center pw.showAtLocation(view, Gravity.CENTER, 0, display.getHeight()/2); } catch (Exception e) { e.printStackTrace(); } } pop_up.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:baselineAligned="false" android:orientation="vertical" android:weightSum="540" android:id="@+id/popup_element" > ... <LinearLayout android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="440" > <com.google.android.maps.MapView android:id="@+id/mapview_popup" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="@string/ApiMapKey" android:clickable="true" /> </LinearLayout> Error 07-23 17:36:28.820: E/MapActivity(12413): Couldn't get connection factory client 07-23 17:36:37.760: E/AndroidRuntime(12413): FATAL EXCEPTION: main 07-23 17:36:37.760: E/AndroidRuntime(12413): android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRoot$W@40590b70 is not valid; is your activity running? 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewRoot.setView(ViewRoot.java:528) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.Window$LocalWindowManager.addView(Window.java:465) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:370) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.MapView.displayZoomControls(MapView.java:1053) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.MapView$1.onDown(MapView.java:341) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:488) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.View.dispatchTouchEvent(View.java:3901) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:869) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2200) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.view.ViewRoot.handleMessage(ViewRoot.java:1884) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.os.Handler.dispatchMessage(Handler.java:99) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.os.Looper.loop(Looper.java:130) 07-23 17:36:37.760: E/AndroidRuntime(12413): at android.app.ActivityThread.main(ActivityThread.java:3835) 07-23 17:36:37.760: E/AndroidRuntime(12413): at java.lang.reflect.Method.invokeNative(Native Method) 07-23 17:36:37.760: E/AndroidRuntime(12413): at java.lang.reflect.Method.invoke(Method.java:507) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 07-23 17:36:37.760: E/AndroidRuntime(12413): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 07-23 17:36:37.760: E/AndroidRuntime(12413): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • android maps: How to Long Click a Map?

    - by vamsibm
    Hi. How do I long click on a mapview so that a place marker appears at that point on the map? I tried a couple ways without success: 1) Using setOnLongClickListener on the MapvView which never detected the longclicks. 2) My other idea was to extend MapView to override dispatchTouchEvent .. Create a GestureDetector to respond to longpress callback. But I was stuck midway here as I could not get a handle to my subclassed Mapview. i.e. MyMapview mymapview; //MyMapView extends MapView mymapView = (MyMapView) findViewById(R.id.map); //results in a classcast exception 3) The only other way I know how to try this is: Detect a MotionEvent.ACTION_DOWN and post a delayed runnable to a handler and detect longpress if the two other events: acton_move or an action_up, have not happened. Can someone provide thoughts on any of these methods to detect long presses? Thanks in advance. Bd

    Read the article

1