public boolean addFragmentToStack(BaseFragment fragment, int position) {
   if (delegate != null && !delegate.needAddFragmentToStack(fragment, this)
       || !fragment.onFragmentCreate()) {
     return false;
   }
   fragment.setParentLayout(this);
   if (position == -1) {
     if (!fragmentsStack.isEmpty()) {
       BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
       previousFragment.onPause();
       if (previousFragment.actionBar != null) {
         ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent();
         if (parent != null) {
           parent.removeView(previousFragment.actionBar);
         }
       }
       if (previousFragment.fragmentView != null) {
         ViewGroup parent = (ViewGroup) previousFragment.fragmentView.getParent();
         if (parent != null) {
           parent.removeView(previousFragment.fragmentView);
         }
       }
     }
     fragmentsStack.add(fragment);
   } else {
     fragmentsStack.add(position, fragment);
   }
   return true;
 }
示例#2
0
 public void setSplitActionBar(boolean z) {
   if (this.d != z) {
     if (this.b != null) {
       LayoutParams layoutParams = new LayoutParams(-2, -1);
       ViewGroup viewGroup;
       if (z) {
         this.b.m1681a(getContext().getResources().getDisplayMetrics().widthPixels, true);
         this.b.m1680a(Integer.MAX_VALUE);
         layoutParams.width = -1;
         layoutParams.height = this.f;
         this.a = (ActionMenuView) this.b.m1678a((ViewGroup) this);
         this.a.setBackgroundDrawable(this.f1088p);
         viewGroup = (ViewGroup) this.a.getParent();
         if (viewGroup != null) {
           viewGroup.removeView(this.a);
         }
         this.c.addView(this.a, layoutParams);
       } else {
         this.a = (ActionMenuView) this.b.m1678a((ViewGroup) this);
         this.a.setBackgroundDrawable(null);
         viewGroup = (ViewGroup) this.a.getParent();
         if (viewGroup != null) {
           viewGroup.removeView(this.a);
         }
         addView(this.a, layoutParams);
       }
     }
     super.setSplitActionBar(z);
   }
 }
  public void setMainView(int id) {
    ViewGroup viewGroup = (ViewGroup) this.activity.findViewById(rootViewId);

    if (id != this.currentMainViewId) {
      for (int index = 0; index < this.topViewArray.length; index++) {
        viewGroup.removeView(this.topViewArray[index]);
      }

      for (int index = 0; index < this.mainViewArray.length; index++) {
        if (id != this.mainViewArray[index].getId()) {
          viewGroup.removeView(this.mainViewArray[index]);
        }
      }

      for (int index = 0; index < this.mainViewArray.length; index++) {
        if (id == this.mainViewArray[index].getId()) {
          viewGroup.addView(this.mainViewArray[index]);
          this.currentMainViewId = id;
        }
      }

      for (int index = 0; index < this.topViewArray.length; index++) {
        viewGroup.addView(this.topViewArray[index]);
      }
    }
  }
示例#4
0
 protected void attachTabToContentView(Tab tab) {
   if ((tab == null) || (tab.getWebView() == null)) {
     return;
   }
   View container = tab.getViewContainer();
   WebView mainView = tab.getWebView();
   // Attach the WebView to the container and then attach the
   // container to the content view.
   FrameLayout wrapper = (FrameLayout) container.findViewById(R.id.webview_wrapper);
   ViewGroup parent = (ViewGroup) mainView.getParent();
   if (parent != wrapper) {
     if (parent != null) {
       Log.w(LOGTAG, "mMainView already has a parent in" + " attachTabToContentView!");
       parent.removeView(mainView);
     }
     wrapper.addView(mainView);
   } else {
     Log.w(LOGTAG, "mMainView is already attached to wrapper in" + " attachTabToContentView!");
   }
   parent = (ViewGroup) container.getParent();
   if (parent != mContentView) {
     if (parent != null) {
       Log.w(LOGTAG, "mContainer already has a parent in" + " attachTabToContentView!");
       parent.removeView(container);
     }
     mContentView.addView(container, COVER_SCREEN_PARAMS);
   } else {
     Log.w(LOGTAG, "mContainer is already attached to content in" + " attachTabToContentView!");
   }
   mUiController.attachSubWindow(tab);
 }
 @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;
   }
 }
示例#6
0
 private void refreshVideoView(int paramInt, FeedViewHolder paramFeedViewHolder)
 {
   ViewGroup localViewGroup = (ViewGroup)paramFeedViewHolder.videoView.getParent();
   if (this.mVideoAttr == null)
     this.mVideoAttr = paramFeedViewHolder.videoView.getAttributes();
   paramFeedViewHolder.videoView.suspend();
   try
   {
     localViewGroup.removeView(paramFeedViewHolder.videoView);
     paramFeedViewHolder.videoView = new SdkVideoView(this.mContext, this.mVideoAttr);
     paramFeedViewHolder.videoView.setId(2131361878);
     localViewGroup.addView(paramFeedViewHolder.videoView);
     initVideoView(paramInt, paramFeedViewHolder);
     return;
   }
   catch (RuntimeException localRuntimeException)
   {
     while (true)
       try
       {
         localViewGroup.removeView(paramFeedViewHolder.videoView);
       }
       catch (Exception localException)
       {
         CrashUtil.logException(localRuntimeException, "Weird things are happening.", new Object[0]);
       }
   }
 }
 private void presentFragmentInternalRemoveOld(boolean removeLast, final BaseFragment fragment) {
   if (fragment == null) {
     return;
   }
   fragment.onPause();
   if (removeLast) {
     fragment.onFragmentDestroy();
     fragment.setParentLayout(null);
     fragmentsStack.remove(fragment);
   } else {
     if (fragment.fragmentView != null) {
       ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent();
       if (parent != null) {
         parent.removeView(fragment.fragmentView);
       }
     }
     if (fragment.needAddActionBar() && fragment.actionBar != null) {
       ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
       if (parent != null) {
         parent.removeView(fragment.actionBar);
       }
     }
   }
   containerViewBack.setVisibility(View.GONE);
 }
  @Override
  public void setAdapter(Adapter adapter) {
    // Only once
    if (mEmptyViewResId != -1) {
      if (null != getParent()) {
        ViewGroup parentView = ((ViewGroup) getParent());
        View tempEmptyView1 = parentView.findViewById(mEmptyViewResId);

        if (null != tempEmptyView1) {
          mEmptyView = tempEmptyView1;

          if (isKeepShowHeadOrFooter) parentView.removeView(tempEmptyView1);
        } else {
          ViewParent pParentView = parentView.getParent();
          if (null != pParentView && pParentView instanceof ViewGroup) {
            View tempEmptyView2 = ((ViewGroup) pParentView).findViewById(mEmptyViewResId);
            if (null != tempEmptyView2) {
              mEmptyView = tempEmptyView2;

              if (isKeepShowHeadOrFooter) ((ViewGroup) pParentView).removeView(tempEmptyView2);
            }
          }
        }
      }
      mEmptyViewResId = -1;
    } else if (isKeepShowHeadOrFooter && null != mEmptyView) {
      ((ViewGroup) mEmptyView.getParent()).removeView(mEmptyView);
    }

    if (null == adapter) {
      if (null != mReqAdapter) {
        if (!isKeepShowHeadOrFooter) {
          mReqAdapter.unregisterAdapterDataObserver(mReqAdapterDataObserver);
        }
        mReqAdapter = null;
        mWrapFamiliarRecyclerViewAdapter = null;

        processEmptyView();
      }

      return;
    }

    mReqAdapter = adapter;
    mWrapFamiliarRecyclerViewAdapter =
        new FamiliarWrapRecyclerViewAdapter(
            this, adapter, mHeaderView, mFooterView, mLayoutManagerType);

    mWrapFamiliarRecyclerViewAdapter.setOnItemClickListener(mTempOnItemClickListener);
    mWrapFamiliarRecyclerViewAdapter.setOnItemLongClickListener(mTempOnItemLongClickListener);

    mReqAdapter.registerAdapterDataObserver(mReqAdapterDataObserver);
    super.setAdapter(mWrapFamiliarRecyclerViewAdapter);

    processEmptyView();
  }
	/**
	 * Sets the list to be used in this pull to refresh container.
	 * @param list the list to use
	 */
	public void setList(ListView list) {
		if (mList != null) {
			mContainer.removeView(mList);
		}
		mList = list;
		if (mList.getParent() != null) {
			ViewGroup parent = (ViewGroup) mList.getParent();
			parent.removeView(mList);
		}
		
		mList.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, getHeight()));
		mContainer.addView(mList, 1);
	}
示例#10
0
 public void remove() {
   if (mHightLightView == null) return;
   ViewGroup parent = (ViewGroup) mHightLightView.getParent();
   if (parent instanceof RelativeLayout || parent instanceof FrameLayout) {
     parent.removeView(mHightLightView);
   } else {
     parent.removeView(mHightLightView);
     View origin = parent.getChildAt(0);
     ViewGroup graParent = (ViewGroup) parent.getParent();
     graParent.removeView(parent);
     graParent.addView(origin, parent.getLayoutParams());
   }
   mHightLightView = null;
 }
示例#11
0
 /**
  * remove a view
  *
  * @param parent
  * @param view
  */
 public static void removeView(ViewGroup parent, View view) {
   // 这里不使用post来做,这样代码更可控,而是改为将refresh下拉动作延后一帧处理,见@link
   // 这里调用removeViewInLayout方法,可以在onLayout的时候调用,否则会产生问题
   if (parent != null && view != null) {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
       if (parent.isInLayout()) {
         parent.removeViewInLayout(view);
       } else {
         parent.removeView(view);
       }
     } else {
       parent.removeView(view);
     }
   }
 }
 public void hide() {
   if (adstir != null) {
     ViewGroup topVIew = (ViewGroup) this.getActivity().findViewById(android.R.id.content);
     topVIew.removeView(adstir);
     adstir = null;
   }
 }
 private void i() {
   Object localObject1 = this.m.getLayoutParams();
   Object localObject2 = getLayoutParams();
   ((ViewGroup.LayoutParams) localObject2).width = ((ViewGroup.LayoutParams) localObject1).width;
   ((ViewGroup.LayoutParams) localObject2).height = ((ViewGroup.LayoutParams) localObject1).height;
   setLayoutParams((ViewGroup.LayoutParams) localObject2);
   if ((this.l & 0x2) != 0) {
     j();
   }
   if ((this.l & 0x1) != 0) {
     localObject2 = new a(getContext());
     ((a) localObject2)
         .setLayoutParams(
             new FrameLayout.LayoutParams(
                 ((ViewGroup.LayoutParams) localObject1).width,
                 ((ViewGroup.LayoutParams) localObject1).height));
     ((a) localObject2).addView(this.m);
     addView((View) localObject2);
     if (this.e != null) {
       localObject1 = this.e.getParent();
       if ((localObject1 instanceof ViewGroup)) {
         ((ViewGroup) localObject1).removeView(this.e);
       }
       int i1 = i.a(getContext(), 33);
       addView(this.e, new FrameLayout.LayoutParams(i1, i1, 53));
     }
     return;
   }
   addView(this.m);
 }
  @Override
  public View createView(Context context, LayoutInflater inflater) {
    if (fragmentView == null) {
      fragmentView = super.createView(context, inflater);
      layoutManager = new LinearLayoutManager(getParentActivity());
      mNodeListView = (LoadMoreRecyclerView) fragmentView.findViewById(R.id.recycleview);
      mNodeListView.setLayoutManager(layoutManager);

      mEmptyContainer =
          (RelativeLayout) fragmentView.findViewById(R.id.swipe_refresh_empty_container);
      footerContainer =
          (FrameLayout) fragmentView.findViewById(R.id.swipe_refresh_footer_container);

      init();

      mNodeListView.setAdapter(mListAdapter);

      // 控制手动加载更多
      mListAdapter.setOnLoadMoreListener(this);
      // 控制自动加载更多
      mNodeListView.setOnLoadMoreListener(this);

      onRefresh();
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }

    return fragmentView;
  }
示例#15
0
    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
      // TODO Auto-generated method stub

      container.removeView((View) object);
      // super.destroyItem(container, position, object);
    }
 @Override
 public void onHideCustomView() {
   // This method must be manually (internally) called on video end in the case of VideoView
   // (typically API level <11)
   // This method must be manually (internally) called on video end in the case of
   // HTML5VideoFullScreen (typically API level 11+) because it's not always called automatically
   // This method must be manually (internally) called on back key press (from this class'
   // onBackPressed() method)
   if (isVideoFullscreen()) {
     // Hide the video view, remove it, and show the non-video view
     activityVideoView.setVisibility(View.GONE); // 播放视频的
     activityVideoView.removeView(videoViewContainer);
     activityNonVideoView.setVisibility(View.VISIBLE);
     ((Activity) activityNonVideoView.getContext())
         .setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // 强制当前页面在手机中竖屏
     // Call back
     if (videoViewCallback != null) videoViewCallback.onCustomViewHidden();
     // Reset video related variables
     isVideoFullscreen = false;
     videoViewContainer = null;
     videoViewCallback = null;
     // Notify full-screen change
     if (toggledFullscreenCallback != null) {
       toggledFullscreenCallback.toggledFullscreen(false);
     }
   }
 }
  /**
   * Sets the Empty View to be used by the Adapter View.
   *
   * <p>We need it handle it ourselves so that we can Pull-to-Refresh when the Empty View is shown.
   *
   * <p>Please note, you do <strong>not</strong> usually need to call this method yourself. Calling
   * setEmptyView on the AdapterView will automatically call this method and set everything up. This
   * includes when the Android Framework automatically sets the Empty View based on it's ID.
   *
   * @param newEmptyView - Empty View to be used
   */
  public final void setEmptyView(View newEmptyView) {
    FrameLayout refreshableViewWrapper = getRefreshableViewWrapper();

    if (null != newEmptyView) {
      // New view needs to be clickable so that Android recognizes it as a
      // target for Touch Events
      newEmptyView.setClickable(true);

      ViewParent newEmptyViewParent = newEmptyView.getParent();
      if (null != newEmptyViewParent && newEmptyViewParent instanceof ViewGroup) {
        ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
      }

      // We need to convert any LayoutParams so that it works in our
      // FrameLayout
      FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams());
      if (null != lp) {
        refreshableViewWrapper.addView(newEmptyView, lp);
      } else {
        refreshableViewWrapper.addView(newEmptyView);
      }
    }

    if (mRefreshableView instanceof EmptyViewMethodAccessor) {
      ((EmptyViewMethodAccessor) mRefreshableView).setEmptyViewInternal(newEmptyView);
    } else {
      mRefreshableView.setEmptyView(newEmptyView);
    }
    mEmptyView = newEmptyView;
  }
  /**
   * Sets the Empty View to be used by the Adapter View.
   *
   * <p>We need it handle it ourselves so that we can Pull-to-Refresh when the Empty View is shown.
   *
   * <p>Please note, you do <strong>not</strong> usually need to call this method yourself. Calling
   * setEmptyView on the AdapterView will automatically call this method and set everything up. This
   * includes when the Android Framework automatically sets the Empty View based on it's ID.
   *
   * @param newEmptyView - Empty View to be used
   */
  public final void setEmptyView(View newEmptyView) {
    // If we already have an Empty View, remove it
    if (null != mEmptyView) {
      mRefreshableViewHolder.removeView(mEmptyView);
    }

    if (null != newEmptyView) {
      // New view needs to be clickable so that Android recognizes it as a
      // target for Touch Events
      newEmptyView.setClickable(true);

      final ViewParent newEmptyViewParent = newEmptyView.getParent();
      if (null != newEmptyViewParent && newEmptyViewParent instanceof ViewGroup) {
        ((ViewGroup) newEmptyViewParent).removeView(newEmptyView);
      }

      mRefreshableViewHolder.addView(
          newEmptyView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

      if (mRefreshableView instanceof EmptyViewMethodAccessor) {
        ((EmptyViewMethodAccessor) mRefreshableView).setEmptyViewInternal(newEmptyView);
      } else {
        mRefreshableView.setEmptyView(newEmptyView);
      }
    }
  }
示例#19
0
  /** Dismisses the SuperCardToast without an animation. */
  public void dismissImmediately() {

    ManagerSuperCardToast.getInstance().remove(this);

    if (mHandler != null) {

      mHandler.removeCallbacks(mHideRunnable);
      mHandler.removeCallbacks(mHideWithAnimationRunnable);
      mHandler = null;
    }

    if (mToastView != null && mViewGroup != null) {

      mViewGroup.removeView(mToastView);

      if (mOnDismissListener != null) {

        mOnDismissListener.onDismiss(getView());
      }

      mToastView = null;

    } else {

      Log.e(TAG, ERROR_VIEWCONTAINERNULL);
    }
  }
示例#20
0
  protected void showPreview() {
    if (null != previewTimer) return;
    game.preview();
    int lastIndex = getBoardSize() - 1;
    final View blankTileCell = imageCells[lastIndex][lastIndex];
    final ViewGroup parent = (ViewGroup) blankTileCell.getParent();
    parent.removeView(blankTileCell);
    countDownCell.setTextColor(getResources().getColor(R.color.countdown_tile_text));
    parent.addView(countDownCell);
    previewTimer =
        new CountDownTimer(3000, 500) {
          @Override
          public void onTick(long millisUntilFinished) {
            int secondsRemaining = Math.round((float) millisUntilFinished / 1000);
            countDownCell.setText(Integer.toString(secondsRemaining));
          }

          @Override
          public void onFinish() {
            hideBoard();
            parent.removeView(countDownCell);
            parent.addView(blankTileCell);
            game.start();
            showImageBoard();
            previewTimer = null;
          }
        };

    previewTimer.start();
  }
示例#21
0
 private void draw() {
   try {
     mLayout.removeView(draw);
   } catch (Exception e) {
   }
   mLayout.addView(draw);
 }
  private void removeAppFromView(int id, ActivityInfo app) {
    Window window = getWindow(id);
    View frame = window.findViewWithTag(app);
    ViewGroup flow = (ViewGroup) window.findViewById(R.id.flow);

    flow.removeView(frame);
  }
示例#23
0
 @Test
 public void removeView_resetsParentOnlyIfViewIsInViewGroup() throws Exception {
   assertThat(root.getChildCount(), equalTo(3));
   root.removeView(child3a);
   assertThat(root.getChildCount(), equalTo(3));
   assertThat(child3a.getParent(), sameInstance((ViewParent) child3));
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (view != null) {
      ViewGroup parent = (ViewGroup) view.getParent();
      if (parent != null) {
        parent.removeView(view);
      }
      return view;
    }
    view = View.inflate(getActivity(), R.layout.fragment_myfavoriate, null);
    listView = (XListView) view.findViewById(R.id.xlistview);
    userId = ((YoutiApplication) getActivity().getApplication()).myPreference.getUserId();

    fl_content = (FrameLayout) view.findViewById(R.id.fl_content);

    v = View.inflate(getActivity(), R.layout.view_error_layout, null);
    iv = (ImageView) v.findViewById(R.id.img_error_layout);
    tv = (TextView) v.findViewById(R.id.tv_error_layout);

    pb = (ProgressBar) v.findViewById(R.id.animProgress);
    listView.setPullLoadEnable(true);
    listView.setPullRefreshEnable(true);
    listView.setXListViewListener(this);
    return view;
  }
  @Override
  public void onHideCustomView() {
    // This method should be manually called on video end in all cases because it's not always
    // called automatically.
    // This method must be manually called on back key press (from this class' onBackPressed()
    // method).

    if (isVideoFullscreen) {
      showActionBar();
      activityNonVideoView.setVideoPlaying(false);
      // Hide the video view, remove it, and show the non-video view
      ViewGroup activityVideoView =
          ((ViewGroup) MainActivity.webLayout.findViewById(R.id.webviewholder));
      activityVideoView.removeView(videoViewContainer);
      activityNonVideoView.setVisibility(View.VISIBLE);

      // Call back (only in API level <19, because in API level 19+ with chromium webview it
      // crashes)
      if (videoViewCallback != null
          && !videoViewCallback.getClass().getName().contains(".chromium.")) {
        videoViewCallback.onCustomViewHidden();
      }

      // Reset video related variables
      isVideoFullscreen = false;
      videoViewContainer = null;
      videoViewCallback = null;

      // Notify full-screen change
      if (toggledFullscreenCallback != null) {
        toggledFullscreenCallback.toggledFullscreen(false);
      }
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {
      fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false);

      TLRPC.Chat currentChat = MessagesController.Instance.chats.get(chat_id);

      firstNameField = (EditText) fragmentView.findViewById(R.id.first_name_field);
      firstNameField.setOnEditorActionListener(
          new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
              if (i == EditorInfo.IME_ACTION_DONE) {
                doneButton.performClick();
                return true;
              }
              return false;
            }
          });
      firstNameField.setText(currentChat.title);
      firstNameField.setSelection(firstNameField.length());

      TextView headerLabel = (TextView) fragmentView.findViewById(R.id.settings_section_text);
      headerLabel.setText(getStringEntry(R.string.EnterGroupNameTitle));
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
示例#27
0
  private void applyTo(View target) {

    LayoutParams lp = target.getLayoutParams();
    ViewParent parent = target.getParent();
    FrameLayout container = new FrameLayout(context);

    if (target instanceof TabWidget) {

      // set target to the relevant tab child container
      target = ((TabWidget) target).getChildTabViewAt(targetTabIndex);
      this.target = target;

      ((ViewGroup) target)
          .addView(container, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

      this.setVisibility(View.GONE);
      container.addView(this);

    } else {

      // TODO verify that parent is indeed a ViewGroup
      ViewGroup group = (ViewGroup) parent;
      int index = group.indexOfChild(target);

      group.removeView(target);
      group.addView(container, index, lp);

      container.addView(target);

      this.setVisibility(View.GONE);
      container.addView(this);

      group.invalidate();
    }
  }
示例#28
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view = inflater.inflate(R.layout.fragment_draw, container, false);
    frame_draw_layout = (LinearLayout) view.findViewById(R.id.frame_draw_layout);
    slidingPaneLayout = new SlidingPaneLayout(getActivity());
    try {
      Field f_overHang = SlidingPaneLayout.class.getDeclaredField("mOverhangSize");
      f_overHang.setAccessible(true);
      f_overHang.set(slidingPaneLayout, 0);
      slidingPaneLayout.setPanelSlideListener(this);
      slidingPaneLayout.setSliderFadeColor(getResources().getColor(android.R.color.transparent));
    } catch (Exception e) {
      e.printStackTrace();
    }

    View leftView = new View(getActivity());
    leftView.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    leftView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    slidingPaneLayout.addView(leftView, 0);

    ViewGroup decor = (ViewGroup) getActivity().getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    decor.removeView(decorChild);
    decor.addView(slidingPaneLayout);
    slidingPaneLayout.addView(decorChild, 1);
    return view;
  }
 public void setParent(android.view.ViewGroup viewgroup) {
   if (parent != null) {
     parent.removeView(this);
   }
   parent = viewgroup;
   viewgroup.addView(this, lparams);
 }
  @Override
  public void onBindView(View view) {
    super.onBindView(view);

    try {
      // move our slider to the new view we've been given
      ViewParent oldContainer = slider.getParent();
      ViewGroup newContainer = (ViewGroup) view.findViewById(R.id.sliderPreferenceSliderContainer);

      if (oldContainer != newContainer) {
        // remove the slider from the old view
        if (oldContainer != null) {
          ((ViewGroup) oldContainer).removeView(slider);
        }
        // remove the existing slider (there may not be one) and add
        // ours
        newContainer.removeAllViews();
        newContainer.addView(
            slider, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      }
    } catch (Exception ex) {
      Log.e(TAG, "Error binding view: " + ex.toString());
    }

    // If parent is disabled, disable the slider.
    if (view != null && !view.isEnabled()) {
      slider.setEnabled(false);
    }

    updateView(view);
  }