Skip to content

Commit ecea3e1

Browse files
author
TetsuyaNegishi
committed
TouchEvent
1 parent 745f83a commit ecea3e1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/com/example/drawapp/SampleView.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
import android.graphics.Canvas;
55
import android.graphics.Color;
66
import android.graphics.Paint;
7+
import android.view.MotionEvent;
78
import android.view.View;
9+
import android.widget.Toast;
810

911
public class SampleView extends View {
1012

1113
private Paint paint = new Paint();
1214
public SampleView(Context context) {
1315
super(context);
14-
setBackgroundColor(Color.BLUE);
16+
setBackgroundColor(Color.WHITE);
1517
}
1618

1719
@Override
1820
public void onDraw(Canvas canvas){
19-
canvas.drawText("Hello", 100, 100, paint);
21+
canvas.drawCircle(100, 100, 20, paint);
2022
}
2123

24+
@Override
25+
public boolean onTouchEvent(MotionEvent event){
26+
Toast.makeText(getContext(), "Touch", Toast.LENGTH_SHORT).show();
27+
return true;
28+
}
2229
}

0 commit comments

Comments
 (0)