Hi all, tried to find an answer on Google/SO but n...
# getting-started
w
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
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)
You don’t need to pass all arguments of your class to the super constructor
w
ah that’s super helpful, thank you!
m
you're welcome