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


Java ViewGroup.getResources方法代碼示例

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


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

示例1: onCreateViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(),
            R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:18,代碼來源:GridItemPresenter.java

示例2: createRowViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
    mR = parent.getResources();

    // We create the base class view holder first
    ViewHolder fullWidthViewHolder = (ViewHolder)super.createRowViewHolder(parent);

    // We expand the info view and put it inside the parent fullwidth container
    ViewGroup fullwidthContainer = (ViewGroup)fullWidthViewHolder.getMainContainer();
    View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.androidtv_details_text_only_group, fullwidthContainer, false);
    fullwidthContainer.addView(detailsView);

    fullwidthContainer.setBackgroundColor(mColor);

    return new FullTextRowViewHolder(fullWidthViewHolder, detailsView);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:FullTextRowPresenter.java

示例3: createRowViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
    mR = parent.getResources();

    // We create the base class view holder first
    FullWidthRowPresenter.ViewHolder fullWidthViewHolder = (FullWidthRowPresenter.ViewHolder)super.createRowViewHolder(parent);

    // We expand the info view and put it inside the parent fullwidth container
    ViewGroup fullwidthContainer = (ViewGroup)fullWidthViewHolder.getMainContainer();
    View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.androidtv_detailled_info_group, fullwidthContainer, false);
    fullwidthContainer.addView(detailsView);

    fullwidthContainer.setBackgroundColor(mColor);

    return new FileDetailsViewHolder(fullWidthViewHolder, detailsView);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:FileDetailsRowPresenter.java

示例4: createRowViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
    mR = parent.getResources();

    // We create the base class view holder first
    ViewHolder fullWidthViewHolder = (ViewHolder)super.createRowViewHolder(parent);

    // We expand the info view and put it inside the parent fullwidth container
    ViewGroup fullwidthContainer = (ViewGroup)fullWidthViewHolder.getMainContainer();
    View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.leanback_details_plot_and_genres_group, fullwidthContainer, false);
    fullwidthContainer.addView(detailsView);

    fullwidthContainer.setBackgroundColor(mColor);

    return new PlotAndGenresViewHolder(fullWidthViewHolder, detailsView);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:PlotAndGenresRowPresenter.java

示例5: createRowViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
    mR = parent.getResources();

    // We create the base class view holder first
    ViewHolder fullWidthViewHolder = (ViewHolder)super.createRowViewHolder(parent);

    // We expand the info view and put it inside the parent fullwidth container
    ViewGroup fullwidthContainer = (ViewGroup)fullWidthViewHolder.getMainContainer();
    View detailsView = LayoutInflater.from(parent.getContext()).inflate(R.layout.leanback_details_director_and_cast_group, fullwidthContainer, false);
    fullwidthContainer.addView(detailsView);

    fullwidthContainer.setBackgroundColor(mColor);

    return new CastViewHolder(fullWidthViewHolder, detailsView);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:CastRowPresenter.java

示例6: onCreateViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) {
    ImageView imageView = (ImageView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.lb_fullwidth_details_overview_logo, parent, false);

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.detail_thumb_width);
    int height = res.getDimensionPixelSize(R.dimen.detail_thumb_height);

    if(mSelectedVideo.videoType.equals("episode")) {
        height = res.getDimensionPixelSize(R.dimen.detail_thumb_episode_height);
    }

    imageView.setLayoutParams(new ViewGroup.MarginLayoutParams(width, height));
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    return new ViewHolder(imageView);
}
 
開發者ID:ad-on-is,項目名稱:chilly,代碼行數:19,代碼來源:VideoDetailsFragment.java

示例7: onCreateViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) {
    ImageView imageView =
            (ImageView)
                    LayoutInflater.from(parent.getContext())
                            .inflate(
                                    R.layout.lb_fullwidth_details_overview_logo,
                                    parent,
                                    false);

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.detail_thumb_width);
    int height = res.getDimensionPixelSize(R.dimen.detail_thumb_height);
    imageView.setLayoutParams(new ViewGroup.MarginLayoutParams(width, height));
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    return new ViewHolder(imageView);
}
 
開發者ID:googlesamples,項目名稱:leanback-assistant,代碼行數:19,代碼來源:VideoDetailsFragment.java

示例8: onCreateViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) {
	ImageView imageView = (ImageView) LayoutInflater.from(parent.getContext())
			.inflate(R.layout.lb_fullwidth_details_overview_logo, parent, false);

	Resources res = parent.getResources();
	int width = res.getDimensionPixelSize(R.dimen.detail_thumb_width);
	int height = res.getDimensionPixelSize(R.dimen.detail_thumb_height);
	imageView.setLayoutParams(new ViewGroup.MarginLayoutParams(width, height));
	imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

	return new ViewHolder(imageView);
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:14,代碼來源:EventsDetailsFragment.java

示例9: onCreateViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) {
    ImageView imageView = (ImageView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.lb_fullwidth_details_overview_logo, parent, false);

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.detail_thumb_width);
    int height = res.getDimensionPixelSize(R.dimen.detail_thumb_height);
    imageView.setLayoutParams(new ViewGroup.MarginLayoutParams(width, height));
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

    return new ViewHolder(imageView);
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:14,代碼來源:VideoDetailsFragment.java

示例10: createAndAddEditButton

import android.view.ViewGroup; //導入方法依賴的package包/類
private Button createAndAddEditButton(ViewGroup parent) {
    Resources resources = parent.getResources();
    Button view = DualControlLayout.createButtonForLayout(
            parent.getContext(), true, resources.getString(R.string.select), this);
    view.setId(R.id.payments_section);

    LayoutParams params =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    ApiCompatibilityUtils.setMarginStart(params, mLargeSpacing);
    parent.addView(view, params);
    return view;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:13,代碼來源:PaymentRequestSection.java

示例11: createAndAddChevron

import android.view.ViewGroup; //導入方法依賴的package包/類
private ImageView createAndAddChevron(ViewGroup parent) {
    Resources resources = parent.getResources();
    TintedDrawable chevron = TintedDrawable.constructTintedDrawable(
            resources, R.drawable.ic_expanded, R.color.payments_section_chevron);

    ImageView view = new ImageView(parent.getContext());
    view.setImageDrawable(chevron);

    // Wrap whatever image is passed in.
    LayoutParams params =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    ApiCompatibilityUtils.setMarginStart(params, mLargeSpacing);
    parent.addView(view, params);
    return view;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:16,代碼來源:PaymentRequestSection.java

示例12: onCreateViewHolder

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {

    mDefaultBackgroundColor =
            ContextCompat.getColor(parent.getContext(), R.color.default_background);
    mSelectedBackgroundColor =
            ContextCompat.getColor(parent.getContext(), R.color.selected_background);

    TextView view = new AppCompatTextView(parent.getContext()) {
        @Override
        public void setSelected(boolean selected) {
            updateGridItemBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(),
            R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
開發者ID:ad-on-is,項目名稱:chilly,代碼行數:30,代碼來源:GridItemPresenter.java

示例13: instantiateItem

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public Object instantiateItem(final ViewGroup container, int position) {
    if(mData != null && mData.size() > position){
        ZoomableDraweeView zoomableDraweeView = null;
        if(mImageViewList != null && mImageViewList.length > position && mImageViewList[position] != null){
            zoomableDraweeView = mImageViewList[position];

        }else{
            zoomableDraweeView = new ZoomableDraweeView(container.getContext());
            zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(true);
            // needed for double tap to zoom
            zoomableDraweeView.setIsLongpressEnabled(false);
            zoomableDraweeView.setSwipeDownListener(mSwipeDownListener);
            final ZoomableDraweeView finalZoomableDraweeView = zoomableDraweeView;
            zoomableDraweeView.setTapListener(new DoubleTapGestureListener(finalZoomableDraweeView){
                @Override
                public boolean onSingleTapConfirmed(MotionEvent e) {
                    if(mItemClickListener != null){
                        mItemClickListener.onClick(finalZoomableDraweeView);
                    }
                    return super.onSingleTapConfirmed(e);
                }
            });
            DraweeController controller = Fresco.newDraweeControllerBuilder()
                    .setUri(mData.get(position % mData.size()))
                    .build();
            zoomableDraweeView.setController(controller);
            GenericDraweeHierarchyBuilder builder =
                    new GenericDraweeHierarchyBuilder(container.getResources());
            GenericDraweeHierarchy hierarchy = builder
                    .setFadeDuration(300).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
                    .build();
            if(mPlaceholderImageResId > 0){
                hierarchy.setPlaceholderImage(mPlaceholderImageResId, ScalingUtils.ScaleType.FIT_CENTER);
            }
            if(mFailureImageResId > 0){
                hierarchy.setFailureImage(mFailureImageResId, ScalingUtils.ScaleType.FIT_CENTER);
            }
            zoomableDraweeView.setHierarchy(hierarchy);

            mImageViewList[position] = zoomableDraweeView;
        }
        container.addView(zoomableDraweeView);

        return zoomableDraweeView;
    }

    return null;
}
 
開發者ID:ibosong,項目名稱:CommentGallery,代碼行數:50,代碼來源:LargeImageGalleryAdapter.java


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