Hi all, tried to find an answer on Google/SO but not had much luck - I want to create a class that extends Constraint Layout so that I can add it dynamically to a view based on a toggle switch. I know that extending ConstraintLayout requires 3 constructor methods, but is there a way to pass in additional parameters when initializing the cutsom class? Ie. an array that I can then use in the custom class?
m
Michael
08/24/2020, 1:57 PM
You can use something like this
Copy code
class MyLayout(val customParameter: Type, Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes) : ConstraintLayout(context, attrs, defStyleAttr, defStyleRes)
Michael
08/24/2020, 1:58 PM
You don’t need to pass all arguments of your class to the super constructor