I use recyclerView and a few cardViews with some editTexts on it, for example:
And now I want to modify the design to programmatically display either spinner or editText based on data given to viewHolder.
I have read the official doc about the custom view, but I am not sure if self-implementing onDraw, onMeasure, ..., will be the right way.
I'm also looking into ViewGroup but have not understood it yet.
Thanks :)
There's a simple way to do this. You don't necessarily need some complex custom view for this. You can just put both Spinner
and EditText
on your UI, then just android:visibility=gone
the view that you don't need currently, and android:visibility=visible
the one you need.