Search code examples
androidviewcode-reuse

How to reuse a view which is created from XML?


experts,

I know I cannot put a ListView inside a ScrollView, but the UI I am building contains a SlideShow view(a custom view) followed by a list of items, each of the items is a view inflated from XML. Now I want to populate each item with different data and add it to the ScrollView, how do I reuse this view or do I need to inflate the XML multiple times to get different view objects?


Solution

  • You can't use the same view and you can't clone views. Inflate the xml for each (different) view you need.