Slide 65
Slide 65 text
όΠϯυ͢Δ
class DataClassActivity : AppCompatActivity() {
var users = listOf(
User(name = "takuji31", birthDay = "1987/03/01"),
User(name = "takuji32", birthDay = "1987/03/02"),
User(name = "takuji33", birthDay = "1987/03/03"),
User(name = "takuji24884", birthDay = null)
)
val binding: ActivityDataClassBinding by lazy {
DataBindingUtil.setContentView(this,
R.layout.activity_data_class)
}
override fun onCreate(savedInstanceState: Bundle?) {
binding.user = users.last()
binding.randomButtonClickListener = View.OnClickListener {
binding.user = users[0]
users = users.drop(1) + binding.user
}
}
}