android - Please help solve this listview problem -


i have 3 lines of code use hold state of items in listview wjen scrolling, problem is, last line of code gets executed. please me solve this. 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 state condition gets executed in listview, rest ignored , set gray. 

is there way can join code logic together, 3 conditions can called?.. thank

all 3 lines executed, you're overriding text color next line. use condition instead:

if (priority.equals("low")) {    holder.viewname.settextcolor(color.blue); } else if (priority.equals("medium")) {    holder.viename.settextcolor(color.green); } else if (priority.equals("high")) {    holder.viewname.settextcolor(color.red); } else {    holder.viewname.settextcolor(color.gray); } 

edit: switch statements strings not yet availalbe in java right?


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -