How do I draw a rectangle to a canvas on a button press (Android?)
===

My project actually has quite a few lines of code right now, so I'll save you by only including here what matters. I hope it's enough information to make the issue clear.  

I have two main classes: a 'GraphView' class, and then the main Activity's code. Within GraphView, I've created a function which, essentially, draws a rectangle on a canvas. It's called drawPixel. In GraphView's onDraw method, I call drawPixel a bunch of times, and it draws rectangles to the screen. Now, in the main code, I've programmatically created a layout and a button. What I want is that instead of calling drawPixel in GraphView's onDraw method, I want to draw those rectangles when I click a button. I tried this by doing:

    someButton.setOnClickListener(new View.OnClickListener() { 
    	@Override
    	public void onClick(View v) {
            Canvas canvas = new Canvas(); 
    		// TODO Auto-generated method stub
                for (int i=1; i<50; i++) {
                    someGraphView.drawPixel(canvas, i, i); 
                }
    	    }
    });

It didn't work. The rectangles draw correctly when i call then via onDraw(), but they don't draw at all when I call them from inside a setOnClickListener method. Does anyone know what I'm doing wrong?  