public View layoutHeaderOrFooterView(TiViewProxy viewProxy) {
   TiUIView tiView = viewProxy.peekView();
   if (tiView != null) {
     TiViewProxy parentProxy = viewProxy.getParent();
     // Remove parent view if possible
     if (parentProxy != null) {
       TiUIView parentView = parentProxy.peekView();
       if (parentView != null) {
         parentView.remove(tiView);
       }
     }
   } else {
     tiView = viewProxy.forceCreateView();
   }
   View outerView = tiView.getOuterView();
   ViewGroup parentView = (ViewGroup) outerView.getParent();
   if (parentView != null && parentView.getId() == HEADER_FOOTER_WRAP_ID) {
     return parentView;
   } else {
     // add a wrapper so layout params such as height, width takes in effect.
     TiCompositeLayout wrapper =
         new TiCompositeLayout(viewProxy.getActivity(), LayoutArrangement.DEFAULT, null);
     AbsListView.LayoutParams params =
         new AbsListView.LayoutParams(
             AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);
     wrapper.setLayoutParams(params);
     outerView = tiView.getOuterView();
     wrapper.addView(outerView, tiView.getLayoutParams());
     wrapper.setId(HEADER_FOOTER_WRAP_ID);
     return wrapper;
   }
 }
 @Override
 public Object instantiateItem(View container, int position) {
   synchronized (viewsLock) {
     ViewGroup pager = (ViewGroup) container;
     TiViewProxy tiProxy = mViews.get(position);
     TiUIView tiView = tiProxy.getOrCreateView();
     View view = tiView.getOuterView();
     ViewGroup.LayoutParams params =
         new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
     TiCompositeLayout layout = new TiCompositeLayout(tiProxy.getActivity());
     ViewParent parent = view.getParent();
     if (parent instanceof ViewGroup) {
       pager.removeView((View) parent);
       ViewGroup group = (ViewGroup) parent;
       group.removeView(view);
     }
     layout.addView(view, tiView.getLayoutParams());
     if (position < pager.getChildCount()) {
       pager.addView(layout, position, params);
     } else {
       pager.addView(layout, params);
     }
     return tiProxy;
   }
 }