Skip to content

Instantly share code, notes, and snippets.

@chrisbanes
Last active December 31, 2018 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbanes/8a0b99f0a6b1578be535c4a822df501b to your computer and use it in GitHub Desktop.
Save chrisbanes/8a0b99f0a6b1578be535c4a822df501b to your computer and use it in GitHub Desktop.
blog_DataBinding_customadapter
/* Copyright 2018 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
@BindingAdapter("maxLinesToggle")
fun maxLinesClickListener(view: TextView, collapsedMaxLines: Int) {
// Default to the collapsed number of max lines
view.maxLines = collapsedMaxLines
// Now set click listener which toggles between this and MAX_INT
view.setOnClickListener(MaxLinesToggleClickListener(...))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment