От чего наследует DrawView?Почему бы не использовать простой XML-макет, где вы размещаете TextView и используете setVisible
внутри вашего OnClickListener
Пример кода:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_view);
Button myButton = (Button) findViewById(R.id.my_button);
final MySurfaceView surfaceView = (MySurfaceView) findViewById(R.id.mysurface);
myButton.setOnClickListener(new OnClickListener() {
@Override
public boolean onClick(View v) {
// here you should change the position and the text you want to write
// like surfaceView.setCoordinates(x, y);
// and surfaceView.setTextToDraw("myText");
return true;
}
});
}
Конечно, вам нужно создать свой собственный SurfaceView.Как это сделать в качестве примера: http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html
xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.mypackage.MySurfaceView android:id="@+id/mysurface"
android:layout_width="300dp"
android:layout_height="300dp" />
<Button android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Push it real good!" />
</LinearLayout>