Ink
05/18/2021, 1:00 PMprivate fun setActiveLabel(textView: TextView) {
binding.apply {
accounts.isSelected = binding.accounts == textView
cards.isSelected = binding.cards == textView
loans.isSelected = binding.loans == textView
funds.isSelected = binding.funds == textView
accounts.isActivated = binding.accounts == textView
cards.isActivated = binding.cards == textView
loans.isActivated = binding.loans == textView
funds.isActivated = binding.funds == textView
}
when (textView) {
binding.accounts -> { binding.accounts.setFocusForAccessibility() }
binding.cards -> { binding.cards.setFocusForAccessibility() }
binding.loans -> { binding.loans.setFocusForAccessibility() }
binding.funds -> { binding.funds.setFocusForAccessibility() }
}
}
bezrukov
05/18/2021, 1:05 PMwhen
by switching to textView.setFocusForAccessibility()
.bezrukov
05/18/2021, 1:07 PMsetActiveLabel
is rare and you don't care about allocating 4 element list, you can use:
binding.apply {
listOf(accounts, cards, loans, funds).forEach { view ->
view.isSelected = view === textView
view.isActivated = view === textView
}
}
Ink
05/18/2021, 1:08 PM