0

I was working on making an android app and I have two points p1 and p2. Depending on what the user does, the location of the points will vary. For example they might be: Point p1= new Point(123,123); Point p2= new Point(234,686); I want to draw a line between these point. However when I checked what methods I could use for the point object, there was no method that would return just the x or y value of the point object. How would I draw a line between these two points then?

Jade
  • 71
  • 1
  • 12
  • possible duplicate of [How to draw a line in android](http://stackoverflow.com/questions/3616676/how-to-draw-a-line-in-android) – Zeus Aug 19 '14 at 21:41

2 Answers2

3

x and y are public fields, you don't need a method to access them.

Also, Canvas.drawLine can take an array of points, so you don't need to read them if you're using that.

FunkTheMonk
  • 10,908
  • 1
  • 31
  • 37
2

Point class is simple as hell, x and y are public fields, so all what you have to do is:

int x = p1.x 
Marurban
  • 1,575
  • 1
  • 9
  • 9