-
-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zebra view #106
Comments
Hi @joegillian You can do whatever you want to do actually. Please check the #69 issue.
Could you please share your screen as gif maybe? Thanks |
@joegillian , if(YPosition is odd {
set colorA // handle both cases
} else {
set colorB // handle both cases
} don't forget you are using a RecycleView, so cell might be recycle and come to you with parameter (like background), you are not expecting. so you have to style up everything again to make sure it match current context. |
hi again, i did it as you mentioned on issue #69 but still same. Could it be that i set the background on wrong place? i do it in the onBindCellViewHolder. |
Hi @joegillian, You need to update each of the background value of cell item. Assume that you have an tableView like this.1.cellA : blue
|
Thanks, I did it as you say and it works perfect. |
Great! I think, the easiest way setting background color at binding process. @Override
public void onBindCellViewHolder(AbstractViewHolder holder, Object cellItemModel, int
columnPosition, int rowPosition) {
Cell cell = (Cell) cellItemModel;
// Determine the right color considering to the row position;
int bgColor = rowPosition % 2 == 0 ? myFirstColor : mySecondColor;
// Set the background color to model
cell.setBackgroundColor(bgColor);
// Get the holder to update cell item value
MyCellViewHolder viewHolder = (MyCellViewHolder) holder;
viewHolder.setCell(cell);
} With this way, It will set the right color every time, not just for once. However, after sorting process, you need to call notifyDataSetChanged as well. Because, the cell items whose positions are unchanged after the sorting process, won't be notified. |
I tried both this solution and the one at 69, it didn't work, also I have to change bg color of cell like this |
Hi,
Thanks for this great library.
Is it possible you to add zebra view feature, so that odd/even rows or columns have different background colors?
I managed to do it by checking cells' positions and setting their background colors. At first it seemed ok but if I sort the rows everything becomes messed up because row's background does not get updated by their new order.
Thanks again.
The text was updated successfully, but these errors were encountered: