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.stanzione.licensesmanagement.ui.CompanyRecyclerAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_company_list_item, null);
    return new ViewHolder(v);

}

From source file:com.mohammedsazid.android.szlauncher.DrawerAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;//from  ww w  . j a  v a  2 s  .c  o  m

    if (viewType == HEADER_TYPE) {
        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.drawer_header, parent, false);
        return new ViewHolder(view, viewType);
    } else if (viewType == ROW_TYPE) {
        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.drawer_row, parent, false);
        return new ViewHolder(view, viewType);
    }

    return null;
}

From source file:com.naman14.timber.adapters.SongsListAdapter.java

@Override
public ItemHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    return new ItemHolder(
            ItemSongBinding.inflate(LayoutInflater.from(viewGroup.getContext()), viewGroup, false), songIDs);
}

From source file:com.bayapps.android.robophish.ui.tv.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    LogHelper.d(TAG, "onCreateViewHolder");
    mContext = parent.getContext();

    ImageCardView cardView = new ImageCardView(mContext);
    cardView.setFocusable(true);/*from  w w w.j ava  2  s .  c om*/
    cardView.setFocusableInTouchMode(true);
    cardView.setBackgroundColor(mContext.getResources().getColor(R.color.default_background));
    return new CardViewHolder(cardView);
}

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

@Nullable
@Override/*w  w  w .j a  v a  2s.  co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_list_swipe, container, false);
    ButterKnife.inject(this, view);

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

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

            return new CardViewHolder(view);
        }
    });

    listView.setLayoutManager(new LinearLayoutManager(listView.getContext()));
    listView.setAdapter(listAdapter);

    refreshView.setOnRefreshListener(() -> {
        load();
    });

    return view;
}

From source file:com.pipit.agc.adapter.DayPickerVerticalAdapter.java

@Override
public CardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.dayofweek_layout, parent, false);
    CardViewHolder vh = new CardViewHolder(v);
    return vh;//w w  w.j  av  a 2  s. c o m
}

From source file:net.olejon.mdapp.DiseasesAndTreatmentsSearchAdapter.java

@Override
public DiseasesAndTreatmentsSearchViewHolder onCreateViewHolder(final ViewGroup viewGroup, final int i) {
    View view = LayoutInflater.from(viewGroup.getContext())
            .inflate(R.layout.activity_diseases_and_treatments_search_card, viewGroup, false);
    return new DiseasesAndTreatmentsSearchViewHolder(view);
}

From source file:com.stanzione.licensesmanagement.ui.ContactRecyclerAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_contact_list_item, null);
    return new ViewHolder(v);

}

From source file:com.fuzz.emptyhusk.prefab.InlineAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    int resId = (position % 3 == 0) ? R.drawable.rectangle_wide_secondary : R.drawable.rectangle_wide_tertiary;

    ImageView inflated = new ImageView(container.getContext());
    inflated.setImageResource(resId);/*from  w w w.ja v a 2  s.  co  m*/
    container.addView(inflated);

    viewCache.put(position, inflated);

    return inflated;
}

From source file:com.rowland.movies.ui.adapters.TrailerAdapter.java

@Override
public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    // Layout to inflate for CustomViewHolder
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.inc_trailer_detail, parent, false);
    // Return new new CustomViewHolder
    return new CustomViewHolder(v);
}