안드로이다 (1) 썸네일형 리스트형 [Android / Kotlin] DataBinding을 사용해 findViewById()를 대체하기 데이터 바인딩을 사용해 findViewById()을 대체하는 과정 1. build.gradle 파일의 안드로이드 섹션에 data binding을 가능하게 한다. buildFeatures { dataBinding true } 2. XML layout 파일에 태그를 root view로 선언한다. '''''' 3. MainActivity에 바인딩 변수를 선언한다. private lateinit var binding: ActivityMainBinding 4. 바인딩 객체를 만들고, 기존의 setContentView를 대체한다. binding = DataBindingUtil.setContentView(this, R.layout.activity_main) 5. findViewById()를 바인딩 객체로 대체한다. .. 이전 1 다음