當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getParent方法代碼示例

本文整理匯總了Java中android.view.View.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getParent方法的具體用法?Java View.getParent怎麽用?Java View.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.getParent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: childAtPosition

import android.view.View; //導入方法依賴的package包/類
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
開發者ID:privacyidea,項目名稱:privacyidea-authenticator,代碼行數:19,代碼來源:MainActivityTest.java

示例2: getLaunchProviderRecursive

import android.view.View; //導入方法依賴的package包/類
/**
 * Recursively finds the parent of the given child which implements IconLogInfoProvider
 */
public static LaunchSourceProvider getLaunchProviderRecursive(View v) {
    ViewParent parent = null;

    if (v != null) {
        parent = v.getParent();
    } else {
        return null;
    }

    // Optimization to only check up to 5 parents.
    int count = MAXIMUM_VIEW_HIERARCHY_LEVEL;
    while (parent != null && count-- > 0) {
        if (parent instanceof LaunchSourceProvider) {
            return (LaunchSourceProvider) parent;
        } else {
            parent = parent.getParent();
        }
    }
    return null;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:24,代碼來源:UserEventDispatcher.java

示例3: refreshStatus

import android.view.View; //導入方法依賴的package包/類
public void refreshStatus(){
    if (container!=null){
        if (flag == Hide){
            container.setVisibility(View.GONE);
            return;
        }
        if (container.getVisibility() != View.VISIBLE)container.setVisibility(View.VISIBLE);
        View view = null;
        switch (flag){
            case ShowMore:view = moreView;break;
            case ShowError:view = errorView;break;
            case ShowNoMore:view = noMoreView;break;
        }
        if (view == null){
            hide();
            return;
        }
        if (view.getParent()==null)container.addView(view);
        for (int i = 0; i < container.getChildCount(); i++) {
            if (container.getChildAt(i) == view)view.setVisibility(View.VISIBLE);
            else container.getChildAt(i).setVisibility(View.GONE);
        }
    }
}
 
開發者ID:ynztlxdeai,項目名稱:TextReader,代碼行數:25,代碼來源:DefaultEventDelegate.java

示例4: calculateClippingRect

import android.view.View; //導入方法依賴的package包/類
/**
 * Can be used by view that support {@code removeClippedSubviews} property to calculate area that
 * given {@param view} should be clipped to based on the clipping rectangle of it's parent in
 * case when parent is also set to clip it's children.
 *
 * @param view view that we want to calculate clipping rect for
 * @param outputRect where the calculated rectangle will be written
 */
public static void calculateClippingRect(View view, Rect outputRect) {
  ViewParent parent = view.getParent();
  if (parent == null) {
    outputRect.setEmpty();
    return;
  } else if (parent instanceof ReactClippingViewGroup) {
    ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent;
    if (clippingViewGroup.getRemoveClippedSubviews()) {
      clippingViewGroup.getClippingRect(sHelperRect);
      // Intersect the view with the parent's rectangle
      // This will result in the overlap with coordinates in the parent space
      if (!sHelperRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
        outputRect.setEmpty();
        return;
      }
      // Now we move the coordinates to the View's coordinate space
      sHelperRect.offset(-view.getLeft(), -view.getTop());
      sHelperRect.offset(view.getScrollX(), view.getScrollY());
      outputRect.set(sHelperRect);
      return;
    }
  }
  view.getDrawingRect(outputRect);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:33,代碼來源:ReactClippingViewGroupHelper.java

示例5: setMenuView

import android.view.View; //導入方法依賴的package包/類
/**
 * Sets the menu view.
 *
 * @param menuView View that becomes the menu view.
 */
public void setMenuView(View menuView) {
    if (menuView.getParent() != null) {
        throw new IllegalStateException("Your menu view already has a parent. Please make sure your menu view does not have a parent.");
    }

    mMenuView = this.findViewWithTag(TAG_MENU);
    if (mMenuView != null) {
        this.removeView(mMenuView);
    }
    mMenuView = menuView;
    mMenuView.setTag(TAG_MENU);
    addView(mMenuView);
    invalidate();
    requestLayout();
}
 
開發者ID:PSD-Company,項目名稱:duo-navigation-drawer,代碼行數:21,代碼來源:DuoDrawerLayout.java

示例6: onWindowAttributesChanged

import android.view.View; //導入方法依賴的package包/類
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
    // Update window manager if: we have a view, that view is
    // attached to its parent (which will be a RootView), and
    // this activity is not embedded.
    if (mParent == null) {
        View decor = mDecor;
        if (decor != null && decor.getParent() != null) {
            getWindowManager().updateViewLayout(decor, params);
        }
    }
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:12,代碼來源:a.java

示例7: replaceView

import android.view.View; //導入方法依賴的package包/類
public static View replaceView(View srcView, int destId) {
    Context context = srcView.getContext();
    ViewGroup viewParent = (ViewGroup) srcView.getParent();
    View destView = LayoutInflater.from(context).inflate(destId, viewParent, false);
    if (destView.getParent() != null) {
        destView.setVisibility(VISIBLE);
    } else {
        viewParent.addView(destView);
    }
    srcView.setVisibility(GONE);
    return destView;
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:13,代碼來源:ViewConverter.java

示例8: removeViewFromParent

import android.view.View; //導入方法依賴的package包/類
/**
 * Remove the given view from its parent.
 *
 * @param view view to remove from its parent
 */
private static void removeViewFromParent(final View view) {
    final ViewParent parent = view.getParent();
    if (parent instanceof ViewGroup) {
        ((ViewGroup) parent).removeView(view);
    }
}
 
開發者ID:wayfair,項目名稱:brickkit-android,代碼行數:12,代碼來源:StickyViewBehavior.java

示例9: PHEmptyDataSet

import android.view.View; //導入方法依賴的package包/類
public PHEmptyDataSet(View fatherView){
    super(fatherView.getContext());
    mcontext = fatherView.getContext();
    this.isFirstCreated = false;
    this.msuperGroup = (ViewGroup) fatherView.getParent();
    this.mfatherView = fatherView;
    ViewGroup.LayoutParams mparam = mfatherView.getLayoutParams();
    this.setLayoutParams(mparam);
    this.imageBTN = new ImageView(mcontext);
    this.imageBTN.setId(9527);
    titleV = new TextView(mcontext);
}
 
開發者ID:HeterPu,項目名稱:PHEmptyDataSetForAndroid,代碼行數:13,代碼來源:PHEmptyDataSet.java

示例10: removeFromParent

import android.view.View; //導入方法依賴的package包/類
/**
 * 從View的Parent中移除該View
 *
 * @param view 要移除的View對象
 */
public static void removeFromParent(View view) {
    if (null != view) {
        ViewParent parent = view.getParent();
        if (null != parent && parent instanceof ViewGroup) {
            ((ViewGroup) parent).removeView(view);
        }
    }
}
 
開發者ID:yhyzgn,項目名稱:TabPager,代碼行數:14,代碼來源:ViewUtils.java

示例11: requestDisallowInterceptTouchEvent

import android.view.View; //導入方法依賴的package包/類
/**
 * 是否請求當前view的父view不要攔截事件
 *
 * @param view
 * @param disallowIntercept true-請求父view不要攔截,false-父view可以攔截
 */
public static void requestDisallowInterceptTouchEvent(View view, boolean disallowIntercept)
{
    ViewParent parent = view.getParent();
    if (parent == null)
    {
        return;
    }
    parent.requestDisallowInterceptTouchEvent(disallowIntercept);
}
 
開發者ID:zj565061763,項目名稱:switchbutton,代碼行數:16,代碼來源:FTouchHelper.java

示例12: onClick

import android.view.View; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
    View editView = (View) view.getParent();
    if (activity.isConnected) {
        View cardView = (View) editView.getParent();
        final int itemPosition = activity.ruleList.getChildLayoutPosition(cardView);
        activity.editRule(activity.rules.get(itemPosition));
    } else {
        Snackbar.make(activity.findViewById(android.R.id.content), R.string.not_connected,
                Snackbar.LENGTH_SHORT).show();
    }
    MainActivity.fadeView(false, editView);
}
 
開發者ID:j4velin,項目名稱:HueNotifier,代碼行數:14,代碼來源:RuleAdapter.java

示例13: onClick

import android.view.View; //導入方法依賴的package包/類
@Override
public void onClick(View view) {
    if (view.getId() != R.id.file_browser_list_item_button) {
        throw new IllegalStateException("Unhandled view in onClick: " + view.toString());
    }

    RelativeLayout parent = (RelativeLayout) view.getParent();
    ViewHolder holder = (ViewHolder) parent.getTag();
    ListItem listItem = getItem(holder.position);
    if (mListener != null && listItem != null) {
        mListener.playItems(listItem.getMediaItems());
    }
}
 
開發者ID:stephenmcgruer,項目名稱:simple-upnp,代碼行數:14,代碼來源:FileBrowserAdapter.java

示例14: prepare

import android.view.View; //導入方法依賴的package包/類
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup) target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 0, 1, 1),
            ObjectAnimator.ofFloat(target, "scaleX", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target, "scaleY", 0.1f, 0.475f, 1),
            ObjectAnimator.ofFloat(target, "translationY", distance, -60, 0)
    );
}
 
開發者ID:weileng11,項目名稱:KUtils-master,代碼行數:12,代碼來源:ZoomInUpAnimator.java

示例15: syncFragmentViewState

import android.view.View; //導入方法依賴的package包/類
private void syncFragmentViewState(Fragment fragment) {
    final View view = fragment.getView();
    if(view != null){
        ViewGroup viewGroup = (ViewGroup) view.getParent();
        if (viewGroup != null && viewGroup.getChildAt(viewGroup.getChildCount() - 1) != fragment.getView()) {
            viewGroup.removeView(view);
            viewGroup.addView(view);
        }
    }

}
 
開發者ID:myl2ning,項目名稱:fragmentnav,代碼行數:12,代碼來源:FragmentTaskManager.java


注:本文中的android.view.View.getParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。