Example usage for android.view ViewGroup getContext

List of usage examples for android.view ViewGroup getContext

Introduction

In this page you can find the example usage for android.view ViewGroup getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.amanmehara.programming.android.adapters.DetailAdapter.java

@Override
public DetailAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.files_list, viewGroup, false);
    return new ViewHolder(view);
}

From source file:com.example.android.myargmenuplanner.FoodsAdapter.java

@Override
public FoodsAdapterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {

    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.list_item_foods, viewGroup, false);
    view.setFocusable(true);/*from ww  w.  j  a v  a 2  s.  c om*/

    return new FoodsAdapterViewHolder(view);
}

From source file:com.github.retrofit2.app.ListFragment.java

@Nullable
@Override/*from w w  w . j  av a2  s. c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    listView = (RecyclerView) inflater.inflate(R.layout.fragment_list, container, false);

    listAdapter = ListRecyclerAdapter.create();
    listAdapter.createViewHolder(new Func2<ViewGroup, Integer, ItemViewHolder>() {
        @Override
        public ItemViewHolder call(ViewGroup parent, Integer position) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);

            /*
            TypedValue typedValue = new TypedValue();
            parent.getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground, typedValue, true);
            view.setBackgroundResource(typedValue.resourceId);
            */

            return new ItemViewHolder(view);
        }
    });
    listView.setLayoutManager(new LinearLayoutManager(listView.getContext()));
    listView.setAdapter(listAdapter);

    return listView;
}

From source file:com.scooter1556.sms.androidtv.presenter.MediaElementPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    defaultBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.default_background);
    selectedBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.selected_background);

    defaultDirectoryIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_directory);
    defaultAudioIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_audio);
    defaultVideoIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_video);

    ImageCardView view = new ImageCardView(parent.getContext()) {
        @Override/*from w  ww  .  j  av  a 2  s . c  o m*/
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    updateCardBackgroundColor(view, false);
    return new ViewHolder(view);
}

From source file:com.amazon.android.tv.tenfoot.presenter.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {

    Context context = parent.getContext();
    try {//from  www . java2  s  .  c  o  m
        mDefaultCardImage = ContextCompat.getDrawable(context, R.drawable.movie);
        sFocusedFadeMask = ContextCompat.getDrawable(context, R.drawable.content_fade_focused);
    } catch (Resources.NotFoundException e) {
        Log.e(TAG, "Could not find resource ", e);
        throw e;
    }

    ImageCardView cardView = new ImageCardView(context) {
        @Override
        public void setSelected(boolean selected) {

            super.setSelected(selected);
            if (mInfoField != null) {
                mInfoField.setBackground(sFocusedFadeMask);
            }
        }
    };
    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);

    // Set the type and visibility of the info area.
    cardView.setCardType(BaseCardView.CARD_TYPE_INFO_OVER);
    cardView.setInfoVisibility(BaseCardView.CARD_REGION_VISIBLE_ALWAYS);

    int CARD_WIDTH_PX = 160;
    mCardWidthDp = Helpers.convertPixelToDp(context, CARD_WIDTH_PX);

    int CARD_HEIGHT_PX = 120;
    mCardHeightDp = Helpers.convertPixelToDp(context, CARD_HEIGHT_PX);

    TextView subtitle = (TextView) cardView.findViewById(R.id.content_text);
    if (subtitle != null) {
        subtitle.setEllipsize(TextUtils.TruncateAt.END);
    }

    mInfoField = cardView.findViewById(R.id.info_field);
    if (mInfoField != null) {
        mInfoField.setBackground(sFocusedFadeMask);
    }

    return new ViewHolder(cardView);
}

From source file:com.saulmm.cui.recycler.ProductAdapter.java

@Override
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final ItemProductBinding productBinding = ItemProductBinding
            .inflate(LayoutInflater.from(parent.getContext()), parent, false);

    return new ProductViewHolder(productBinding);
}

From source file:com.scooter1556.sms.android.presenter.MediaItemPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    defaultBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.primary);
    selectedBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.primary_dark);

    defaultDirectoryIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.tv_folder);
    defaultAudioIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.tv_audio);
    defaultVideoIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.tv_video);
    defaultMediaIcon = ContextCompat.getDrawable(parent.getContext(), R.drawable.tv_play);

    ImageCardView view = new ImageCardView(parent.getContext()) {
        @Override/*w ww  . j  a v  a2  s  .  c  om*/
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    view.setFocusable(true);

    updateCardBackgroundColor(view, false);
    return new ViewHolder(view);
}

From source file:com.zhihu.android.app.mirror.widget.adapter.ArtboardPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    ArtboardLayout layout = (ArtboardLayout) LayoutInflater.from(container.getContext())
            .inflate(R.layout.pager_item_artboard, container, false);
    container.addView(layout);//ww  w.  ja va 2  s  . com

    Artboard artboard = mList.get(position);
    layout.setTag(R.id.artboard_position, position);
    layout.setTag(R.id.artboard_id, artboard.getId());
    layout.setArtboard(artboard);

    return layout;
}

From source file:com.mummyding.app.leisure.support.adapter.ReadingAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_reading, parent, false);
    ViewHolder vh = new ViewHolder(itemView);
    return vh;/*from  w  ww.j a va2s.c  om*/
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserAdapter.java

@Override
public SignBrowserAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new ViewHolder(
            LayoutInflater.from(parent.getContext()).inflate(R.layout.browser_row_layout, parent, false));
}