Drawing vectors to a canvas and associating elements in those vectors?
<p>I am trying to achieve some text on circles. What I have at the minute are two vectors, one for holding Strings and the other for holding Drawables.</p>

<p>In my onDraw() method I loop through and draw each drawable on to the canvas. I want to find a way to associate the String vector elements and the elements in the Drawable vector.</p>

<p>For example: a user taps on circle 3, they then click to add text to the circle and once these steps are complete, circle 3 knows that it's corresponding text is in element 3 of the Strings vector. So in onDraw(), the Drawable vector can be drawn to the canvas followed by the Strings holding text for each circle....</p>

<p>Some code I have at the minute:</p>

<p>A user clicks to add text to a circle, a dialog pops up and asks for the user the enter the text they would like on the circle.</p>

<pre><code>stringsVector.setSize(vecForShapes.size());//set the Strings vector to the size of the Drawable vector, because there will never be more text than circles

stringsVector.add(circleID, circleText);//add circleText to the Strings vector at position circleID.
</code></pre>

<p>now in my onDraw() I redraw both vectors and put the text on the bounds of that circle:</p>

<pre><code>for(int i =0;i&lt;_vecForShapes.size();i++)
        {
        Rect bounds = ((Drawable) _vecForShapes.get(i)).getBounds();//get circle i

        String tempString = stringVect.get(i);//get string i

        if(tempString !=null)
         if(tempString.length() &gt; 17)
         {
            canvas.drawText(tempString, 0, 11, bounds.left+10, bounds.top+30, colour);
            canvas.drawText(tempString, 11,tempString.length(), bounds.left+5, bounds.top+40, colour);
         }//end if
         else
         {
             canvas.drawText(tempString,0,tempString.length(), bounds.left+5, bounds.top+40, colour);
         }
        }
</code></pre>

<p>I know there are probably many better ways to do this but I am too far in to change this now, but I am still willing to listen to peoples opinions so I will know better next time..</p>

<p>Thanks!</p>
