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);

}

}

'Android' 카테고리의 다른 글

If you use RESULT_OK, onActivityResult() is not called.  (0) 2013.05.23
HOW TO DEBUG ANDROID WIDGETS  (0) 2013.05.18
SurfaceView in Layout  (0) 2013.05.14
ndk hello world usage  (0) 2013.05.12
custom font setting  (0) 2013.05.07