I'm using a Adapter
and RecyclerView
. I try to change the color of the first item in my RecyclerView
. I do this in my onBindViewHolder
and the first one indeed changes how i want it to but if i check 8 views furter i see that that one is changed aswell. It's a bit consistant, item number 0 is changed, 1,2,3,4 isn't 5 is, 6,7,8,9 isn't 10 is etc...
If I go debugging i see that my if statement is getting triggerd alot of time's. If i search on internet I see people use the same kinda way (in onBindViewHolder
). Dont know what im doing wrong :(
@Override
public void onBindViewHolder(@NonNull oScheduleAvailabilityViewHolder scheduleAvailabilityViewHolder, int position) {
oSchedule oSchedule = oScheduleArrayList.get(position);
scheduleAvailabilityViewHolder.scheduleAvailabilityTextView.setTypeface((oSchedule.getSelected()) ? Typeface.DEFAULT_BOLD : Typeface.SANS_SERIF);
scheduleAvailabilityViewHolder.scheduleAvailabilityTextView.setText(oSchedule.getScheduleName());
if (position == 0) {
scheduleAvailabilityViewHolder.scheduleAvailabilityTextView.setTextColor(0xFFd45155);
scheduleAvailabilityViewHolder.test.setBackgroundColor(0xFF1D3587);
}
}
I want only the first item (adapterPosition 0 or position 0) to be changed in color and background. Right now also a consistant amount of other views are.