Android

Custom view 생성

tomato13 2013. 5. 17. 05:49

http://sdw8001.tistory.com/42


At first, I made only default constructor and there's an error. I knew that at least three constructors should be declared. 


// 사용하려는 목적에 따라 기타 함수는 다르겠지만 아래의 것들은 꼭 있어야 한다.

// 없으면 xml에서 속성들이 적용되지 않아서 컴파일은 되어도 실행이 안된다.

public class MyView extends View {

public MyView(Context context) {

super(context);

}


public MyView(Context context, AttributeSet attrs) {

super(context, attrs);

}

public MyView(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);

}

}