class MyView extends View
{
Paint dotPaint;
boolean mContextVariable;
List<Point> points = new ArrayList<Point>();
Point p = new Point();
public MyView(Context context)
{
super(context);
dotPaint = new Paint();
dotPaint.setColor(Color.YELLOW);
}
@Override
protected void onDraw(Canvas canvas)
{
canvas.drawARGB(100, 100, 100, 255);
int xCenter = canvas.getWidth()/2;
int yCenter = canvas.getHeight()/2;
Functions fc = new Functions();
MainActivity layout = new MainActivity();
int coordmax = (fc.countChar(layout, "coordsWalked.pkm", "§") - 1) / 2;
invalidate();
int loop = 1;
while (loop <= coordmax){
int lat = Integer.parseInt(fc.getDataSplit(layout, "coordsWalked.pkm", ((coordmax*2)-1)))+xCenter;
int lng = Integer.parseInt(fc.getDataSplit(layout, "coordsWalked.pkm", ((coordmax*2))))+yCenter;
p.x = lat;
p.y = lng;
points.add(p);
loop++;
}
for(Point p: points){
canvas.drawCircle(p.x, p.y, 10, dotPaint);
invalidate();
}
invalidate();
}
*"coordsWalked.pkm" is a text file that has a series of coordinates separated by a splitter so that *2 - 1 is the x coordinate and 2 - 0 is the y coordinate. No need to worry about this too much, all of my circles are being drawn at exactly the correct coordinates, and thus in the correct place.
The problem is that it only draws a circle at the last coordinate in the text file. What I want is for it to draw circles for every single one of the coordinates in the file and show them at the same time, but instead it only ever shows the last circle. I tried to solve this using the for(Point p: points) solution I found online, but it still runs exactly the same as before. I've also tried tweaking the invalidates, turning them off and on etc, but it makes no apparent difference.
I've sifted through tons of answers, but none of them work for me. Some of them don't work because they use different methods to draw the circles that I don't understand or is not practical for me to use (like using surfaceView), and for others I have no idea why they don't work. The code I have now is partially from another answer I found online that didn't work for me.