title: MvvmCross: Polymorphic list within fragment based tab view
body: <p>I am trying to create a GUI which uses fragment based TabView. The code is based on the FragmentSample found in MvvmCross tutorials. The number of tabs within the TabView depends on data read from xml file and every tab uses the same fragment. So far everything workes OK. The problems started when I tried to add polymorphic list to the fragment. The code used to create polymorhpic list is basically the same as found in Collection sample(again from MvvmCross tutorials).</p>
  
  <p>First i tried to create the list adapter and assign it to the MvxListView within Activity associated with the TabView(class extending MvxTabsFragmentActivity). In that class I override the OnViewModelSet() method. Within the override I create an ListAdapter which extends MvxAdapter and assign it to the list. The problem is that the GetBindableView(View convertedView, object dataContext, int templateId) method in the adapter never gets called so all items in the list are shown by calling the ToString() method on items bound to the list. Maybe it is worth mentioning that if I define the DataTemplate within the .axml file the list works ok - but is not polymorphic. </p>
  
  <p>Then I tried to move the code used to create the ListAdapter to the class associated with the fragment - the one derived from MvxFragment - which seems better since the list is located inside the fragment. Since I wasn't sure which method to override I first tried the OnAttach method which yielded in an exception saying that the BindingContext cannot be used at this time. When I put the code in the Resume() method of the fragment things finally started working. For the Context instance needed when creating the adapter I just used the base.Activity.</p>
  
  <p>So finally to my question. Is the solution described above OK - is the OnResume() method the one to create the list adapter or should I use some different approach. As I said - everything seem to be working OK I am just not sure if this is the best(good) solution.</p>
  
  <p>I hope the post is not to long - I tried to be as brief as possible without omitting important details. Any advice will be appreciated.</p>
  
  <p>Uros</p>