public TiUIFragment(TiViewProxy proxy, Activity activity) {
    super(proxy);
    // When 'fragmentOnly' property is enabled, we generate the standalone fragment, enabling
    // us to add it directly to other fragment managers.
    if (proxy.hasProperty(TiC.PROPERTY_FRAGMENT_ONLY)) {
      fragmentOnly = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_FRAGMENT_ONLY), false);
    }

    if (fragmentOnly) {
      fragment = createFragment();
    } else {
      TiCompositeLayout container =
          new TiCompositeLayout(activity, proxy) {
            @Override
            public boolean dispatchTouchEvent(MotionEvent ev) {
              return interceptTouchEvent(ev) || super.dispatchTouchEvent(ev);
            }
          };
      container.setId(viewId++);
      setNativeView(container);

      FragmentManager manager = ((FragmentActivity) activity).getSupportFragmentManager();
      FragmentTransaction transaction = manager.beginTransaction();
      fragment = createFragment();
      transaction.add(container.getId(), fragment);
      transaction.commitAllowingStateLoss();
    }
  }
 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;
   }
 }