onDraw cannot access non-static variables
<p>I'm encountering issue displaying given text at given position using a custom textview.</p>

<p>I want to create N MyTextView disposed in a circular way, using this code:</p>

<pre><code>for (int i = 0; i &lt; player_num ; i++){
         x = (x_offset+(raggio*Math.sin((degree_offset)*i)));
         y = (y_offset+(raggio*Math.cos((degree_offset)*i)));
         //System.out.println("x: "+x+" y: "+y);
         player_name = new MyTextView(mCtx,x,y,String.valueOf(i+1));

}
</code></pre>

<p>This is a piece of my class which extends TextView, I pass x,y coordinates and the string to display:</p>

<pre><code>public MyTextView(Context context, double x, double y, String text) {
    super(context);
    System.out.println("constructor called");

    mx = x;
    my = y;
    mtext = text;
    initBrushes();
    System.out.println("constructor x: "+mx+" y: "+my+" text: "+mtext);
}




@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    // Get the size of the control based on the last call to onMeasure.
    int height = getMeasuredHeight();
    int width = getMeasuredWidth();
    System.out.println("ondraw called");

    System.out.println("draw x: "+mx+" y: "+my+" text: "+mtext);

    // Find the center
    int px = width / 2;
    int py = height / 2;
    // Define the string.
    // Measure the width of the text string.
    float textWidth = mTextPaint.measureText(mtext);
    // Draw the text string in the center of the control.
    canvas.drawText(mtext, Math.round(mx) - textWidth / 2, Math.round(my)- textWidth, mTextPaint); 
    //canvas.drawText(this.text, Math.round(this.x), Math.round(this.y),  mTextPaint);

}
</code></pre>

<p>With this code I get NullPointer because the onDraw cant access the content of the variables, with the      </p>

<pre><code>System.out.println("draw x: "+mx+" y: "+my+" text: "+mtext);
</code></pre>

<p>I get " 0.0 0.0 null ", instead, if I define variables as static, I get the last value assigned to them (of course):</p>

<pre><code>constructor called
constructor x: 160.0 y: 320.0 text: 1
constructor called
constructor x: 206.44889473698515 y: 305.1344776421249 text: 2
constructor called
constructor x: 235.63561239368934 y: 266.0625044428118 text: 3
ondraw called
draw x: 235.63561239368934 y: 266.0625044428118 text: 3
</code></pre>

<p>What am I doing wrong ? Why the onDraw cant access class variables except static ones ?</p>

<p>Thanks </p>
