본문 바로가기

분류 전체보기158

[Kotlin] 순열 구하기 코틀린에서 순열을 구하는 방법.  1. 순열의 개념순열이란 순서에 상관있는 배열을 말합니다. 예를 들어, 숫자 배열 [1, 2, 3]에서 순열을 구하면 다음과 같은 모든 조합이 나옵니다:[1, 2, 3][1, 3, 2][2, 1, 3][2, 3, 1][3, 1, 2][3, 2, 1]이런 조합들을 구하는 것이 순열.  fun getPermutations(arr: MutableList, depth: Int, n: Int, result: MutableList>) { if (depth == n) { result.add(arr.toList()) // 배열의 복사본을 추가 return } for (i in depth until n) { arr.swap(dept.. 2024. 9. 23.
[Android Studio] Drop down 사용하기 xml style activity private fun regionCodeInit() { val regionArray = resources.getStringArray(R.array.license_drop_down_list) val arrayAdapter = ArrayAdapter(this, R.layout.item_license_drop_down, regionArray) binding.autoCompleteTextView.setAdapter(arrayAdapter) binding.autoCompleteTextView.setOnItemClickListener { parent, view, position, id -> when (position) { 0 -> Toast.makeText(this, "Expose.. 2024. 4. 12.
[Flutter] 에러 해결 The method 'File.create' has fewer named arguments than those of overridden method 'File.create'. 참고 블로그 https://cishome.tistory.com/270 [flutter] Error (Xcode): ../../../../../.pub-cache/hosted/pub.dev/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The metho 몇 달간 들여다 보지 않았던 flutter 로 프로젝트 연습 하던 내용을 다시 보려고 iphone simulator 로 실행했더니 아래와 같은 에러가 나타났습니다. Error (Xcode): ../../../../../.pub-cache/hosted/pub.dev/file-6.1.2/l cishome.tistory.com 터미널에 입력 1. flutter pub outdated 2. flutter pub up.. 2024. 4. 3.
[Android Studio] ScrollView 방향 확인 법 응용. (코틀린) 전에 포스팅 했던 ScrollView 의 방향을 활용해서 응용할 수 있는 코드를 포스팅 하겠습니다. 활용 내용은 특정 위치를 계산해서 스크롤이 그 특정 뷰 보다 내려가는지 올라가는지 활용하는 것이 목표입니다. 특정 뷰의 좌표를 알 수 있는 방법으로 getLocationOnScreen 을 활용한다. val location = IntArray(2) // Array를 준비. textView.getLocationOnScreen(location) val x = location[0] // textView 의 x 값 val y = location[1] // textView 의 y 값 이제 응용한다면 내려가면서 특정 뷰의 위치를 지날 때와 , 올라가면서 특정 뷰의 위치를 지날때를 분기로 처리할 수 있다. scrollV.. 2024. 3. 23.
[Android Studio] StatusBar 색상 변경하기 (코틀린) 안드로이드에서 흔히 쓰이는 StatusBar 색상 변경 코드이다. window.statusBarColor = ContextCompat.getColor(this.context, color) // StatusBar 색상 변경 여기에 더해서 StatusBar 아이콘들의 색상을 흰색 또는 검정색으로 바꾸는 코드가 있다. StatusBar 를 흰색으로 지정해서 아이콘이 안보일 시 사용할 수 있다. val window = window val decorView = window.decorView val wic = WindowInsetsControllerCompat(window, decorView) wic.isAppearanceLightStatusBars = bool // true 면 검정색 false 면 흰색이 된다... 2024. 3. 21.
[Android Studio] ScrollView 방향 확인 법 1. (코틀린) 오늘은 안드로이드 스크롤 뷰 활용 시 활용될 수 있는 스크롤 방향에 대해서 포스팅하겠습니다. 내가 화면을 위로 내리는지 , 아래로 내리는지 알고 싶을 때 활용합니다. setOnScrollChangeListener 를 활용. scrollView.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY -> if (scrollY > oldScrollY) { // 스크롤을 아래로 내릴 때. } if (scrollY < oldScrollY) { // 스크롤을 위로 올릴 때. } } } 이상입니다 2024. 3. 20.