Pin several images at touch points - Android -


am trying place pins wherever user touches on imageview. assume map (like google maps) & user touches point, point a, , pin drawn @ point. then, user touches point b, pin (not same previous pin relocated!) needs drawn @ point b , on. right now, able draw pin @ point user touches on screen :

@override public void ondraw(canvas canvas) { ....     bitmap marker = bitmapfactory.decoderesource(getresources(),             r.drawable.icon_locationmarker);     canvas.drawbitmap(marker, mlasttouchx, mlasttouchy, null); ....      canvas.restore(); } 

however, don't want relocate 1 pin across screen wherever user touches (which above code doing). want put several pins @ points wherever user touches. new android. please help.

eluvatar right, needs create list store mark. here's sample of code. remember, add list when motionevent either action_up or action_down only. otherwise, there full of point.

public arraylist<coordinate> pointslist;  @override public void ondraw(canvas canvas) { ....     bitmap marker = bitmapfactory.decoderesource(getresources(),             r.drawable.icon_locationmarker);     for(coordinate coor : pointslist){         canvas.drawbitmap(marker, coor.x, coor.y, null);     }  ....      canvas.restore(); }  public view.ontouchlistener mlistener = new view.ontouchlistener() {      @override     public boolean ontouch(view v, motionevent event) {          if (event.getaction() == android.view.motionevent.action_up) {             pointslist.add(new coordinate(event.getx(), event.gety()));         }          return false;     } };  class coordinate{     float x;     float y;     public coordinate(float x, float y){         this.x = x;         this.y = y;     } } 

edit: change int x,y float x,y


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -