My drawing app runs well ,but when I want to see my drawing, I need to press my home button and launch it again.
I want to know why my app doesn't show my drawing at the moment.
public class MainActivity extends ActionBarActivity {
private MyView vw;
//정점 하나에 대한 정보를 가지는 클래스
public class Vertex {
Vertex(float ax, float ay , boolean ad) {
x= ax;
y= ay;
Draw= ad;
}
float x;
float y;
boolean Draw;
}
ArrayList<Vertex> arVertex;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
vw = new MyView(this);
setContentView(vw);
arVertex=new ArrayList<Vertex>();
}
protected class MyView extends View {
Paint mPaint;
public MyView(Context context) {
super(context);
//Paint 객체 미리 초기화
mPaint=new Paint();
mPaint.setColor(Color.BLACK);
mPaint.setStrokeWidth(3);
mPaint.setAntiAlias(true);
}
public void onDraw(Canvas canvas) {
canvas.drawColor(Color.LTGRAY);
/*정점을 순회하면서 선분으로 있는다.*/
for(int i=0;i<arVertex.size();i++) {
if(arVertex.get(i).Draw) {
canvas.drawLine(arVertex.get(i-1).x,arVertex.get(i-1).y,arVertex.get(i).x,arVertex.get(i).y, mPaint);
}
}
}
//터치 이동시마다 정점추가
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction()==MotionEvent.ACTION_DOWN) {
arVertex.add(new Vertex(event.getX(),event.getY(),false));
return true;
}
if (event.getAction()==MotionEvent.ACTION_MOVE) {
arVertex.add(new Vertex(event.getX(),event.getY(),true));
return true;
}
return false;
}
}
}
I want to know why my app doesn't show my drawing at the moment. Sorry