How to drawText when button click? How can I setContentView(R.layout.main) to see the button and draw the text when button click? I cannot make it, and below is my code for drawing text.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawView = new DrawView(this);
setContentView(drawView);
}
public DrawView(Context context) {
super(context);
textpaint.setColor(Color.WHITE);
}
public void onDraw(Canvas canvas) {
canvas.drawText("Testing", 20, 55, textpaint);
}
What does DrawView inherite from?
Why not using a simple xml layout where you place a TextView and use
setVisibleinside yourOnClickListenerSample code:
You need to create your own SurfaceView of course. How to do that as an example: http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html
xml: