I have this 3 lines of code which I use to hold the state of items in my listview when scrolling, but my problem is, the last line of code only gets executed. This is the code block:
holder.viewName.setTextColor((priority.equals("Low")? Color.BLUE: Color.GRAY ) );
holder.viewName.setTextColor((priority.equals("Medium")? Color.GREEN: Color.GRAY ) );
holder.viewName.setTextColor((priority.equals("High")? Color.RED: Color.GRAY ) ); // items in this state condition only gets executed in the listview, the rest are ignored and set to gray.
Is there a way I can join the code logic together, so that all 3 conditions can be called?
All 3 lines get executed, but you’re always overriding the text color with the next line. Use a condition instead:
Edit: Switch statements for strings is not yet availalbe in Java right?