Skip to content

Instantly share code, notes, and snippets.

@douglasiacovelli
Created January 23, 2018 11:38
Show Gist options
  • Select an option

  • Save douglasiacovelli/01b5fac377554a33c05b4ff8aa8db51a to your computer and use it in GitHub Desktop.

Select an option

Save douglasiacovelli/01b5fac377554a33c05b4ff8aa8db51a to your computer and use it in GitHub Desktop.
class BenefitView(context: Context, attrs: AttributeSet): LinearLayout(context, attrs) {
init {
inflate(context, R.layout.benefit_view, this)
val imageView: ImageView = findViewById(R.id.image)
val textView: TextView = findViewById(R.id.caption)
val attributes = context.obtainStyledAttributes(attrs, R.styleable.BenefitView)
imageView.setImageDrawable(attributes.getDrawable(R.styleable.BenefitView_image))
textView.text = attributes.getString(R.styleable.BenefitView_text)
attributes.recycle()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment