How to pass string value to textview in another class dynamically?
<p>My Code:</p>

<p>Edit as per comment by Graham</p>

<p>PaintView.java</p>

<pre><code>public class PaintView extends View {

private Bitmap mBitmap;
private Canvas mCanvas;
private Path mPath;
private Paint mPaint;
private static final int TOUCH_TOLERANCE_DP = 20;
private static final int BACKGROUND = 0xFFDDDDDD;
private List&lt;Point&gt; mPoints = new ArrayList&lt;Point&gt;();
private int mLastPointIndex = 0;
private int marks = 0;
private int mTouchTolerance;
private boolean isPathStarted = false;

@Override
protected void onDraw(Canvas canvas) {
    canvas.drawColor(BACKGROUND);
    canvas.drawBitmap(mBitmap, 0, 0, null);
    canvas.drawPath(mPath, mPaint);

    // TODO remove if you dont want points to be drawn
    for (Point point : mPoints) {
        canvas.drawPoint(point.x, point.y, mPaint);
    }
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            touch_start(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE:
            touch_move(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP:
            touch_up(x, y);
            invalidate();
            break;
    }
    return true;
}

private void touch_start(float x, float y) {

    if (checkPoint(x, y, mLastPointIndex)) {
        mPath.reset();
        // user starts from given point so path can beis started
        isPathStarted = true;
    } else {
        // user starts move from point which doen's belongs to mPinst list
        isPathStarted = false;
    }

}

//ADDED WITH LAST EDIT
private void touch_move(float x, float y) {
    // draw line with finger move
    if (isPathStarted) {
        mPath.reset();
        Point p = mPoints.get(mLastPointIndex);
        mPath.moveTo(p.x, p.y);
        if (checkPoint(x, y, mLastPointIndex + 1)) {
            p = mPoints.get(mLastPointIndex + 1);
            mPath.lineTo(p.x, p.y);
            mCanvas.drawPath(mPath, mPaint);
            mPath.reset();
            ++mLastPointIndex;
            marks++;
            update();
        } else {
            mPath.lineTo(x, y);
        }
    }
}

private void update() {
    // TODO Auto-generated method stub
    String newMarks  = "";
    newMarks = Integer.toString(marks);
    Log.e("Marks", ":" + newMarks);
}

/**
 * Draws line.
 */
private void touch_up(float x, float y) {
    mPath.reset();
    marks--;
    update();
    if (checkPoint(x, y, mLastPointIndex + 1) &amp;&amp; isPathStarted) {
        // move finished at valid point so draw whole line

        // start point
        Point p = mPoints.get(mLastPointIndex);
        mPath.moveTo(p.x, p.y);
        // end point
        p = mPoints.get(mLastPointIndex + 1);
        mPath.lineTo(p.x, p.y);
        mCanvas.drawPath(mPath, mPaint);
        mPath.reset();
        // increment point index
        ++mLastPointIndex;
        isPathStarted = false;
    }

}
}
</code></pre>

<p>MainActivity.java</p>

<pre><code>public class MainActivity extends Activity {

    TextView textView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = (TextView)findViewById(R.id.marks_id);
        //update();
    }

    /*private void update() {
        // TODO Auto-generated method stub
        String newMarks  = "";
        newMarks = Integer.toString(marks);
        TextView textView = (TextView)findViewById(R.id.marks_id);
        textView.setText(newMarks);
    }*/



}
</code></pre>

<p>I want to get the value of marks from PaintView.java and assign that value to textView in MainActivity.java. Its a kind of noob question, but please help me with this.</p>
