I have a TableView that adds a TableRow for each entry in an XML file that it parses from.
To set the background color, I am currently using:
TableRow.setBackgroundResource(color);
How can I set it so each TableRow alternates background colors?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A simple and straightforward solution could be, as you iterate over each entry in the XML file, keep a counter. If the counter is odd, use
color1, if the counter is even, usecolor2.