android - Get and compare EditText background color -


i developing android app have few edittexts. setting background color of edittext dynamically 1 have defined in res/drawable folder. want background color of edittext , compare hex color, e-g if color #ff0000 change text color of edittext white. how setting background color of edittext:

allscaleedittexts.get(row_col).setbackgroundresource             (r.drawable.edittext_bgcolor_one); 

that how getting background color of edittext:

drawable scaleedtxtcolor = allscaleedittexts.get(row_col)                 .getbackground(); 

now want make comparison like:

if(scaleedtxtcolor == #ff0000)             allscaleedittexts.get(row_col).settextcolor(color.white);         else             allscaleedittexts.get(row_col).settextcolor(color.black); 

i don't know how go comparison. have tried this:

if(scaleedtxtcolor == color.parsecolor("#ff0000")) 

but error of comparing drawable int. how can solve it?

you can't use

if(scaleedtxtcolor == #ff0000) 

cause drawable.

i think need scalededtxtcolor.getcolorfilter set color with:

scalededtxtcolor.setcolorfilter(color.red, porterduff.mode.src_atop); 

have there.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -