본문 바로가기

728x90

전체 글

(229)
TextView MultiLine 처리 - TextView 에 긴 줄의 Text 를 처리할 때 일반적으로 안드로이드 고정된 Width 의 TextView 에서 자동으로 글자 수에 따라 다음 줄로 처리되어 있다. 그리고 끝을 "..." 으로 끝내고 싶을 때에는 아래의 속성을 추가한다. android:ellipsize="end" - MultiLine TextView 왼쪽에 다른 아이템이 있을 경우에는 가변적으로 TextView Width 처리를 한다. 1. 가변 처리를 하지 않을 경우 2. 가변 처리를 할 경우 - 가변 처리 방법 코드 상에서 아래와 같이 조건에 따라 가변 처리를 수행한다.
Subroutine override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val sum = (0..10).toMutableList().sum() result_text.text = "Result : $sum" // sum() 연산이 끝난 후 결과 return } // Subroutine private fun MutableList.sum(): Int = this.sumBy { it }
MutableList * sum() The examples show you how to use sum() function to: sum of all items in the normal List sum of specific field in List of Objects (in need of map()) sum of specific field of all values in a Map (in need of map()) Why we need map()? map() will create a List of quantity first, then we invoke: List.sum() List We’re gonna use sum() on List and List for example. val nums = listOf(10, 20, 30) p..
Set up for coroutine ext.coroutineVersion = '1.0.0' // official version // for coroutine implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
Set up for Rxkotlin implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'io.reactivex.rxjava2:rxjava:2.2.17' implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0' implementation 'com.jakewharton.rxbinding3:rxbinding:3.1.0' implementation 'com.uniquext.android:rxlifecycle:2.0.0'