how to get a context in a recycler view adapter

Solutions on MaxInterview for how to get a context in a recycler view adapter by the best coders in the world

showing results for - "how to get a context in a recycler view adapter"
Fynn
18 Mar 2017
1private Context context;
2
3@Override
4public FeedAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
5    // create a new view
6    View v=LayoutInflater.from(parent.getContext()).inflate(R.layout.feedholder, parent, false);
7    // set the view's size, margins, paddings and layout parameters
8    ViewHolder vh = new ViewHolder(v);
9    // set the Context here 
10    context = parent.getContext();
11    return vh;
12}
13
similar questions