MovieHunt blog part5. epoxy model custom view sample
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT) | |
class DropdownItemView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : LinearLayout(context, attrs, defStyleAttr) { | |
@TextProp | |
var itemText: CharSequence? = null | |
@ModelProp | |
fun selected(selected: Boolean = false) { | |
textMenuItem.isSelected = selected | |
} | |
@CallbackProp | |
var clickListener: OnClickListener? = null | |
private val textMenuItem: TextView | |
init { | |
View.inflate(context, R.layout.item_dropdown_menu, this) | |
orientation = VERTICAL | |
textMenuItem = findViewById(R.id.textMenu) | |
} | |
@AfterPropsSet | |
fun userProps() { | |
textMenuItem.text = itemText | |
textMenuItem.setOnClickListener(clickListener) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment