I have a ListAdapter with a lot of different layouts for the rows. To have a clean code I want to outsource the layouts for the rows from the getView() of the adapter in View classes. Is it possible to inflate a XML layout into a custom view? I've only found the LayoutInflater but it returns a View and that does not help. I want to have something like the setLayout() of an Activity. Is this possible?
Thanks!
I alwas use a custom Adapter with a viewholder like:
}
You can have a custom row view and inflate your xml in its constructor:
and then use
merge
inmy_row.xml
:The
merge
element causes its children to be added as children of your custom view. Check out Merging Layouts for more info.