티스토리 뷰
안드로이드/코틀린
[Android Studio] 코틀린 클래스 오버로딩 커스텀뷰 Class Overloading Constructor Kotlin
eqrw105 2021. 4. 19. 20:29[Android Studio] 코틀린 클래스 오버로딩 커스텀뷰 Class Overloading Constructor Kotlin
1. Java -> Kotlin
public class Pen extends View{
public Pen(Context context) {
super(context);
init(context);
}
public Pen(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public Pen(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
}
open class DrawViewT: View {
constructor(context: Context) : this(context, null)
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super (context, attrs, defStyleAttr)
}
2. Java -> Kotlin
public class Pen {
public int x, y;
public Pen(){
}
public Pen(int x, int y){
this.x = x;
this.y = y;
}
}
open class Pen() {
open var x by Delegates.notNull<Float>()
open var y by Delegates.notNull<Float>()
constructor(x: Float, y: Float): this(){
this.x = x
this.y = y
}
}
'안드로이드 > 코틀린' 카테고리의 다른 글
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 깃허브에서 깃랩으로
- kakao api notworking
- 라이브러리 라이센스
- 커밋 이메일 변경
- next.js ssr deploy
- Build failed because of webpack errors
- kotlin
- 깃랩 잔디 옮기기
- amplify build error
- 깃랩에서 깃허브로
- next useEffect
- Android Studio
- 깃허브 잔디 옮기기
- 안드로이드 해시키
- react.js useEffect
- github mirror
- react native 오픈소스 라이선스
- 카카오 해시키
- 안드로이드 스튜디오
- 안드로이드 스튜디오 해시키
- 코틀린
- amplify next.js
- gitlab mirror
- room error
- react native oss
- rn 오픈소스 라이센스
- non-zero exit code detected
- rn oss
- nextjs ssr deploy
- next.js useEffect
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함