How do I write this code in extension?

How do I write this code in extension?

///This line ///
final View view = LayoutInflater.from(context).inflate(R.layout.item, parent, false);
//////////////////

public ItemAdapter.ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
final View view = LayoutInflater.from(context).inflate(R.layout.item, parent, false);
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (onItemSizeListener != null) {
onItemSizeListener.onItemSize(view.getMeasuredWidth());
}
}
});
return new ViewHolder(view);
}

View view = new View(context);

try this, not tested myself .

are you making extension of recyclerView?
this is an open source extension you may be interested.

Ok thanks I'll check can u tell me about this code

public ViewHolder(final View itemView) {
super(itemView);
rootView = itemView;
picture = (ImageView) itemView.findViewById(R.id.picture);
moreLayout = itemView.findViewById(R.id.more_layout);
pictureLayout = itemView.findViewById(R.id.picture_layout);
}

Is this right?

ImageView picture = new ImageView(context) ;

we can not use R class in extension.
what about compile the extension, then what the compiler feedback?

Getting error object null