๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์ „์ฒด ๊ธ€

(374)
[Android][Toast] Can't toast on a thread that has not called Looper.prepare() Crashlytics์—์„œ ์ด์Šˆ ํ•ด๋‹น ๋ฐœ๊ฒฌ ๋งˆ์ด๋„ˆ ์ด์Šˆ๋กœ ๋“ฑ์žฅํ•˜๊ณ  ์žˆ๋‹ค. (๊ณ  ํŒ๋‹จํ•˜๊ณ  ์žˆ๋‹ค. ์ œ๋ฐœ ๋งˆ์ด๋„ˆ ์ด์Šˆ์—ฌ๋ผ...) ์ด์Šˆ์— ๋Œ€ํ•œ ์„ค๋ช…๋“ค https://stackoverflow.com/a/3875204 Can't create handler inside thread that has not called Looper.prepare() What does the following exception mean; how can I fix it? This is the code: Toast toast = Toast.makeText(mContext, "Something", Toast.LENGTH_SHORT); This is the exception: java.lang.RuntimeExce... stackoverflow...
[Kotlin] Calendar extensions ๊ฐ„๋‹จ val Calendar.year: Int get() = this.get(Calendar.YEAR) val Calendar.month: Int get() = this.get(Calendar.MONTH) val Calendar.day: Int get() = this.get(Calendar.DAY_OF_MONTH) val Calendar.dayOfWeek: Int get() = this.get(Calendar.DAY_OF_WEEK)
[Kotlin] Selection Sort ์ง€์ •ํ•œ ์ž๋ฆฌ์— ํƒ์ƒ‰ ๋ฒ”์œ„(๋น„๊ต ๋Œ€์ƒ)์—์„œ ์ฐพ์€ ๋งž๋Š” ๊ฐ’(๊ฐ€์žฅ ์ž‘๊ฑฐ๋‚˜, ๊ฐ€์žฅ ํฌ๊ฑฐ๋‚˜)์„ ์ฐพ์•„ ๋„ฃ๋Š”๋‹ค. ๊ธฐ๋ณธ swap fun ArrayList.swap(firstIndex: Int, secondIndex: Int) { val temp = this[firstIndex] this[firstIndex] = this[secondIndex] this[secondIndex] = temp } Selection Sort fun ArrayList.selectionSort(showLog: Boolean = true) :ArrayList { if (this.size < 2) { println("๋ฐฐ์—ด ํฌ๊ธฐ : ${this.size}. ๋ฐฐ์—ด ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜") return this } for (currentPosition in 0 u..
[Android][Kotlin] ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ํƒญ์˜ ๋ฌธ๊ตฌ์— ๋ณผ๋“œ ์ฒ˜๋ฆฌ ๊ธฐ๋ณธ Tab ๋ณผ๋“œ ์ฒ˜๋ฆฌ fun TabLayout.Tab.setBold() = this.view.children.find { it is TextView }?.let { tv -> (tv as TextView).post { tv.setTypeface(null, Typeface.BOLD) } } ๋‹ค๋ฅธ Typeface๋กœ ๊ต์ฒด ๊ฐ€๋Šฅ https://developer.android.com/reference/android/graphics/Typeface#summary Typeface | Android Developers developer.android.com ์„ ํƒ์ง€๊ฐ€ 4๊ฐ€์ง€ ๋ฐ–์— ์—†๊ธฐ๋Š” ํ•˜๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒํ•œ ํƒญ์˜ ๋ฌธ๊ตฌ ๋ณผ๋“œ ์ฒ˜๋ฆฌ fun TabLayout.setSelectedTabBold() = this.addOnTa..
[Kotlin] BaseUseCase abstract class UseCase where Type : Any { abstract suspend operator fun invoke(params: Params): Type? }
[Android][Kotlin] ๋ฌธ๊ตฌ ๋ถ€๋ถ„ ์ƒ‰ ๋ณ€๊ฒฝ SpannedString ์ข…์† ํ•ญ๋ชฉ ์„ ์–ธ build.gradle ์•ˆ implementation "androidx.core:core-ktx:$core_version" Utility fun String.targetColorSpan( emphasisString: String, @ColorInt colorRes: Int ): SpannedString { if(!this.contains(emphasisString)) return SpannedString(this) val splitStrings = this.split(emphasisString.toRegex()) return buildSpannedString { append(splitStrings[0]) color(colorRes) { append(emphasisString) } appe..
[Kotlin]Bubble Sort ์ธ์ ‘ํ•œ ๋‘ ๊ฐœ์˜ ์š”์†Œ๋“ค์„ ๋น„๊ตํ•˜๋ฉฐ ์ •๋ ฌํ•œ๋‹ค. ๊ธฐ๋ณธ swap fun ArrayList.swap(firstIndex: Int, secondIndex: Int) { val temp = this[firstIndex] this[firstIndex] = this[secondIndex] this[secondIndex] = temp } Bubble sort fun ArrayList.bubbleSort(showLog: Boolean = true) : ArrayList { if (this.size < 2) { println("๋ฐฐ์—ด์˜ ํฌ๊ธฐ๊ฐ€ 2 ๋ฏธ๋งŒ. ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜.") return this } for (end in lastIndex downTo 1) { var swapped = false for(current in 0 un..
[Android][View] ๋ทฐ๊ฐ€ layout์„ ์ง„ํ–‰ํ•˜๋Š” ์ค‘์— requestLayout()์„ ํ˜ธ์ถœํ•˜๋ฉด ์•ˆ๋œ๋‹ค. https://www.youtube.com/watch?v=HbAeTGoKG6k ๋ฌด๋ ค 13๋…„ ์ „์˜ ์˜์ƒ. ๊ทธ๋Ÿฌ๋‚˜ ์ง€๊ธˆ๋„ ์ค‘์š”ํ•œ ๊ธฐ๋ณธ ์ง€์‹์œผ๋กœ ์•Œ์•„๋‘˜ ํ•„์š”๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. ์š”์•ฝ ์ง„ํ–‰ํ•œ ๋ฐ๋ชจ (์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•ˆ๋ฉ๋‹ˆ๋‹ค. ๋‚˜์œ ์˜ˆ์‹œ) 1. LinearLayout ์„ ์ƒ์†ํ•œ Custom Layout์ด layout ๊ณผ์ •์„ ์ง„ํ–‰ํ•˜๋Š” ์ค‘์—, ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ onLayout()์„ ํ˜ธ์ถœํ•ด ์‹คํ–‰ํ•˜๋Š” ์ค‘์— 2. ์ž๋…€ ๋ทฐ๋ฅผ add ํ•˜๊ฑฐ๋‚˜(addView()) remove ํ•˜๋ฉด(removeView()) 3. ๊ฒฐ๋ก  : ์ด์Šˆ๊ฐ€ ์ƒ๊ธด๋‹ค. > ์ผ์ข…์˜ ์žฌ๊ท€๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด๋‹ค. layout ์ค‘ : ์ผ๋ถ€ ํ•˜์œ„ ์ง‘ํ•ฉ(์ž๋…€ ๋ทฐ๋“ค)์ด๋‚˜ ์ „์ฒด ๋ทฐ ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ์žฌ๋ฐฐ์น˜ํ•˜๋Š” ์ค‘์ธ๋ฐ ์ด ํƒ€์ด๋ฐ์— addView(), removeView() ํ˜ธ์ถœ : ๋ ˆ์ด์•„์›ƒ ์ „์ฒด์— ์˜ํ–ฅ์„..