I have a main class:
public class Main extends Activity { Button edit,save,eraser,clear; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); edit = (Button) findViewById(R.id.edit); save = (Button) findViewById(R.id.save); clear = (Button) findViewById(R.id.clear); eraser = (Button) findViewById(R.id.eraser); eraser.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { GameBoard aa = new GameBoard(Main.this); aa.eraser(); aa.invalidate(); } }); } }
And my view class looks like this:
public class GameBoard extends View{ public void init() { mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true);
Here is the layout:
<com.authorwjf.GameBoard android:id="@+id/the_canvas" android:layout_width="fill_parent" android:layout_height="fill_parent" />
When I click the button, it does not change the mPaint value to eraser .
Can anyone help me?
source share