I am using android.support.v7.widget.RecyclerView to show simple items containing text and in some cases also images. Basically I followed the tutorial from here https://dev
Not sure if people still have issues with this, but the if statement did not work for me. What did work for me is this:
Using an override on this method in the adapter
@Override
public int getItemViewType(int position) {
return position;
}
followed by calling the if statement based on this for the image itself within the onBindViewHolder, like so:
int pos = getItemViewType(position);
if(theList.get(pos).getPicture() == null) {
holder.picture.setVisibility(View.GONE);
} else {
Picasso.with(context).load(R.drawable.robot).into(holder.picture);
}
I am using Picasso but it should work with any other else situation. Hope this helps someone!