I am trying to refactor my ListView to RecyclerView and I stuck in this situation.
In my ListView Adapter i have something like this:
@Override
public int getItemViewType(int position) {
if (mDecommissionMode && position == getCount() - 1)
return 1;
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (getItemViewType(position) == 0)
return getNormalView(position, convertView, parent);
else
return getManualDecommissionView(convertView, parent);
}
I don't have an idea how can I apply this to my RecyclerView adapter because I don't have access to the position in onCreateViewHolder method, where the layout should be inflated.
Here are the methods in my RecyclerView Adapter:
@Override
public DevicesItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
DevicesRecyclerViewAdapter.DevicesItemViewHolder holder = new DevicesItemViewHolder(); //should pass some inflated view to ViewHolder instance
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mOnClickListener.onClick(view);
}
});
return holder;
}
@Override
public void onBindViewHolder(DevicesItemViewHolder holder, int position) {
}
Is there a way I can cope with it?