These names disappear arraylist, how to make them stay in place?

The problem is that the names are set separately Arraylist, but when I save them they disappear as shown on the gif

private ArrayList<String> pinNames = new ArrayList<String>();
int i = 0;

if (i < pinNames.size() && pinNames.get(i) != null )
{
    String p = pinNames.get(i++);
    canvas.drawText("" + p, vX, vY, paint);
}

Answer

Based on your comments to my other answer, here is another attempt:

private ArrayList<String> pinNames = new ArrayList<String>();
private ArrayList<PointF> sPin = new ArrayList<PointF>();

// assert pinNames.size() == sPin.size()

for(int i = 0; i < pinNames.size(); i++)
{
    String pinName = pinNames.get(i);
    PointF pinPosition = sPin.get(i);

    if(pinName != null && pinPosition != null)
    {
        PointF vPin = sourceToViewCoord(pinPosition);
        float vX = vPin.x - (pinBitmap.getWidth() / 2);
        float vY = vPin.y - pinBitmap.getHeight();

        canvas.drawText("" + pinName, vX, vY, paint);
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *