当前位置: 首页>>代码示例>>Java>>正文


Java ViewGroup.getContext方法代码示例

本文整理汇总了Java中android.view.ViewGroup.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.getContext方法的具体用法?Java ViewGroup.getContext怎么用?Java ViewGroup.getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    Log.d(TAG, "onCreateViewHolder");

    sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
    /*
     * This template uses a default image in res/drawable, but the general case for Android TV
     * will require your resources in xhdpi. For more information, see
     * https://developer.android.com/training/tv/start/layouts.html#density-resources
     */
    mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);

    ImageCardView cardView = new ImageCardView(parent.getContext()) {
        @Override
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
}
 
开发者ID:alphater,项目名称:garras,代码行数:27,代码来源:CardPresenter.java

示例2: instantiateItem

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public View instantiateItem(ViewGroup container, final int position) {
    PhotoView photoView = new PhotoView(container.getContext());
    //load full size image with Picasso lib into the photoView
    Picasso.with(container.getContext())
            .load(sDrawables.get(position).getPhoto().getOriginalSize().getUrl())
            .placeholder(R.drawable.ic_sync)
            .error(R.drawable.ic_warning)
            .into(photoView);
    container.addView(photoView, ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);

    photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
        @Override
        public void onViewTap(final View view, float x, float y) {
            //on photo click, display or hide data section
            View photoDataView = findViewById(R.id.photo_data);
            if (photoDataView.getVisibility() == View.VISIBLE) {
                photoDataView.setVisibility(View.GONE);
            } else {
                photoDataView.setVisibility(View.VISIBLE);
            }
        }
    });

    return photoView;
}
 
开发者ID:nioc,项目名称:tumblr-photo-browse,代码行数:27,代码来源:BlogActivity.java

示例3: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public MyComicNumberHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
    context = parent.getContext();
    final MyComicNumberHolder comicNumberHolder = new MyComicNumberHolder(LayoutInflater.from(context).inflate(R.layout.comic_number_recyclerview,parent,false));
    comicNumberHolder.view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int position = comicNumberHolder.getAdapterPosition();
            ComicNumberList comicNumberList = comicNumberLists.get(position);
            comicNumberHolder.comicNumberCardview.setCardBackgroundColor(ContextCompat.getColor(context,R.color.colorPrimary));

            ContentValues values = new ContentValues();
            values.put("readNow",comicNumberList.getComicPages());
            DataSupport.updateAll(ComicMessageItem.class,values,"comicUrl = ?",comicNumberList.getComicUrl());

            //Log.d("readnow",DataSupport.where("comicUrl = ?",comicNumberList.getComicUrl()).find(ComicMessageItem.class).get(0).getReadNow());

            Intent intent = new Intent(context, ComicReadActivity.class);
            intent.putExtra(ComicFragment.COMICREADURL,comicNumberList.getComicPagesUrl());
            context.startActivity(intent);
        }
    });
    return comicNumberHolder;
}
 
开发者ID:NicoLiutong,项目名称:miaosou,代码行数:25,代码来源:ComicNumberAdapter.java

示例4: hookNavBar

import android.view.ViewGroup; //导入方法依赖的package包/类
private static void hookNavBar(ViewGroup rootView, ViewGroup navbarView) {
    rootNavbarView = rootView;
    Context context = rootView.getContext();
    ViewPager vpXpHook = new ViewPager(context);

    exNavbar = new LinearLayout(context);
    musicControllerPanel = new MusicControllerPanel(context);
    onHomeNavbar = new LinearLayout(context);

    initExNavbar(vpXpHook, exNavbar);
    initHomeNavbar(onHomeNavbar, vpXpHook);
    initMusicPanel(musicControllerPanel);
    initVpHook(vpXpHook, navbarView, exNavbar, musicControllerPanel, onHomeNavbar);

    initBroadcast(context);
    initClipBoardListener(context);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
            ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);
    rootView.addView(vpXpHook, 0, params);

    setNavbarHeight(context, DataHook.navbarHeight);
}
 
开发者ID:EggUncle,项目名称:XposedNavigationBar,代码行数:24,代码来源:NavBarHook.java

示例5: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 *
 * This gets called when each new ViewHolder is created. This happens when the RecyclerView
 * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling.
 *
 * @param viewGroup The ViewGroup that these ViewHolders are contained within.
 * @param viewType  If your RecyclerView has more than one type of item (which ours doesn't) you
 *                  can use this viewType integer to provide a different layout. See
 *                  {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)}
 *                  for more details.
 * @return A new NumberViewHolder that holds the View for each list item
 */
@Override
public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    Context context = viewGroup.getContext();
    int layoutIdForListItem = R.layout.number_list_item;
    LayoutInflater inflater = LayoutInflater.from(context);
    boolean shouldAttachToParentImmediately = false;

    View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately);
    NumberViewHolder viewHolder = new NumberViewHolder(view);

    viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount);

    int backgroundColorForViewHolder = ColorUtils
            .getViewHolderBackgroundColorFromInstance(context, viewHolderCount);
    viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder);

    viewHolderCount++;
    Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: "
            + viewHolderCount);
    return viewHolder;
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:34,代码来源:GreenAdapter.java

示例6: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
    public FloatViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        Context context = parent.getContext();
        LayoutInflater inflater =  LayoutInflater.from(context);
        View itemView = inflater.inflate(R.layout.float_status_view, parent, false);
//        int height = parent.getMeasuredHeight() / 4;
//        int width = parent.getMinimumWidth() /3;
//        itemView.setMinimumHeight(height);
//        itemView.setMinimumWidth(width);
        return new FloatAdapter.FloatViewHolder(itemView);
    }
 
开发者ID:Lekky71,项目名称:WhatsAppStatusSaver,代码行数:12,代码来源:FloatAdapter.java

示例7: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LinearLayout linearLayout = new LinearLayout(parent.getContext());
    linearLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    return new ViewHolder(linearLayout) {
    };
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:8,代码来源:RecyclerIndicatorView.java

示例8: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ImageHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    context = parent.getContext();
    View view = LayoutInflater.from(context).inflate
            (R.layout.item_imgselector_pop, parent, false);
    return new ImageHolder(view);
}
 
开发者ID:BittleDragon,项目名称:MyRepository,代码行数:8,代码来源:FolderInfoPopupWindowAdapter.java

示例9: build

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public FocusBorder build(ViewGroup parent)
{
    if (null == parent)
    {
        throw new NullPointerException("The FocusBorder parent cannot be null");
    }
    final ColorFocusBorder boriderView =
        new ColorFocusBorder(parent.getContext(), mShimmerColor, mShimmerDuration, mIsShimmerAnim,
            mAnimDuration, mPaddingOfsetRectF, mShadowColor, mShadowWidth, mBorderColor, mBorderWidth);
    final ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(1, 1);
    parent.addView(boriderView, lp);
    return boriderView;
}
 
开发者ID:Dreamxiaoxuan,项目名称:AndroidTvDemo,代码行数:15,代码来源:ColorFocusBorder.java

示例10: createView

import android.view.ViewGroup; //导入方法依赖的package包/类
/**
 * Utility method to create the view for this router.
 *
 * @param parentViewGroup to inflate view with.
 * @return the view for a new router.
 */
protected final ViewType createView(ViewGroup parentViewGroup) {
  final Context context = parentViewGroup.getContext();
  final ViewType view =
      inflateView(LayoutInflater.from(onThemeContext(context)), parentViewGroup);

  if (XRay.isEnabled()) {
    XRay.apply(this, view);
  }

  return view;
}
 
开发者ID:uber,项目名称:RIBs,代码行数:18,代码来源:ViewBuilder.java

示例11: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch (viewType) {
        case VIEW_TYPE_SECTION_BREAK:
            return new ViewHolder(new View(parent.getContext()));
        case VIEW_TYPE_ICON:
            /* falls through */
        case VIEW_TYPE_PREDICTION_ICON: {
            BubbleTextView icon = (BubbleTextView) mLayoutInflater.inflate(
                    R.layout.all_apps_icon, parent, false);
            icon.setOnClickListener(mIconClickListener);
            icon.setOnLongClickListener(mIconLongClickListener);
            icon.setLongPressTimeout(ViewConfiguration.get(parent.getContext())
                    .getLongPressTimeout());
            icon.setOnFocusChangeListener(mIconFocusListener);

            // Ensure the all apps icon height matches the workspace icons
            DeviceProfile profile = mLauncher.getDeviceProfile();
            Point cellSize = profile.getCellSize();
            GridLayoutManager.LayoutParams lp =
                    (GridLayoutManager.LayoutParams) icon.getLayoutParams();
            lp.height = cellSize.y;
            icon.setLayoutParams(lp);
            return new ViewHolder(icon);
        }
        case VIEW_TYPE_EMPTY_SEARCH:
            return new ViewHolder(mLayoutInflater.inflate(R.layout.all_apps_empty_search,
                    parent, false));
        case VIEW_TYPE_SEARCH_MARKET:
            View searchMarketView = mLayoutInflater.inflate(R.layout.all_apps_search_market,
                    parent, false);
            searchMarketView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mLauncher.startActivitySafely(v, mMarketSearchIntent, null);
                }
            });
            return new ViewHolder(searchMarketView);
        case VIEW_TYPE_SEARCH_DIVIDER:
            return new ViewHolder(mLayoutInflater.inflate(
                    R.layout.all_apps_search_divider, parent, false));
        case VIEW_TYPE_PREDICTION_DIVIDER:
            /* falls through */
        case VIEW_TYPE_SEARCH_MARKET_DIVIDER:
            return new ViewHolder(mLayoutInflater.inflate(
                    R.layout.all_apps_divider, parent, false));
        default:
            throw new RuntimeException("Unexpected view type");
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:51,代码来源:AllAppsGridAdapter.java

示例12: buildView

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
protected Carousel buildView(ViewGroup parent)
{
    return new Carousel(parent.getContext(), null);
}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:6,代码来源:CarouselModel.java

示例13: onCreateViewHolder

import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch (viewType) {
        case ITEM_LEFT:
        case ITEM_LEFT_TEXT:
            Log.i("lin", "+++++lin+++++   1");
            return new LCIMChatItemTextHolder(parent.getContext(), parent, true);
        case ITEM_LEFT_IMAGE:
            Log.i("lin", "+++++lin+++++   2");
            return new LCIMChatItemImageHolder(parent.getContext(), parent, true);
        case ITEM_LEFT_AUDIO:
            Log.i("lin", "+++++lin+++++   3");
            return new LCIMChatItemAudioHolder(parent.getContext(), parent, true);
        case ITEM_LEFT_LOCATION:
            Log.i("lin", "+++++lin+++++   4");
            return new LCIMChatItemLocationHolder(parent.getContext(), parent, true);
        case ITEM_RIGHT:

            return new LCIMChatItemTextHolder(parent.getContext(), parent, false);
        case ITEM_RIGHT_TEXT:
            Log.i("lin", "+++++lin+++++   5" + parent.getContext());
            //Log.i("lin", "+++++lin+++++   5" + parent);

            return new LCIMChatItemTextHolder(parent.getContext(), parent, false);
        case ITEM_RIGHT_IMAGE:
            Log.i("lin", "+++++lin+++++   6");
            return new LCIMChatItemImageHolder(parent.getContext(), parent, false);
        case ITEM_RIGHT_AUDIO:
            Log.i("lin", "+++++lin+++++   7");
            return new LCIMChatItemAudioHolder(parent.getContext(), parent, false);
        case ITEM_RIGHT_LOCATION:
            Log.i("lin", "+++++lin+++++   8");
            return new LCIMChatItemLocationHolder(parent.getContext(), parent, false);

        case TYPE_1000:
        case TYPE_1001:
            Log.i("lin", "---lin--->   我的类型是 1000或者是10001");

            return new OrderHolder(parent.getContext(), parent, true);

        default:
            Log.i("lin", "+++++lin+++++   9");
            return new LCIMChatItemTextHolder(parent.getContext(), parent, true);
    }
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:46,代码来源:LCIMChatAdapter.java

示例14: linkify

import android.view.ViewGroup; //导入方法依赖的package包/类
private static BetterLinkMovementExtended linkify(int linkifyMask, ViewGroup viewGroup) {
    BetterLinkMovementExtended movementMethod = new BetterLinkMovementExtended(viewGroup.getContext());
    rAddLinks(linkifyMask, viewGroup, movementMethod);
    return movementMethod;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:6,代码来源:BetterLinkMovementExtended.java

示例15: newChildView

import android.view.ViewGroup; //导入方法依赖的package包/类
protected View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup viewGroup) {
    InboxMessageView entryView = new InboxMessageView(viewGroup.getContext());
    initMessageView(context, entryView, this.inboxManager.getMessageFromViewCursor(cursor), isLastChild);
    return entryView;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:6,代码来源:InboxCursorAdapter.java


注:本文中的android.view.ViewGroup.getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。