java - Having issues with argb method with Android -
i trying figure out how use argb method http://developer.android.com/reference/android/graphics/color.html.
i've read through multiple times , still can't app work. i'm trying view widget display color made moving 4 sliders no colors show no matter put sliders. thought argb method return value colorvalue
, able use color? suggestions appreciated!
my main class looks this:
public class colorchooseractivity extends activity implements onseekbarchangelistener { //variables private seekbar redseekbar; private seekbar greenseekbar; private seekbar blueseekbar; private seekbar alphaseekbar; private view colorview; private textview colortextview; //instanced variables private static int colorvalue = 0; private int redvalue = 0; private int greenvalue = 0; private int bluevalue =0; private int alphavalue =0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_color_chooser); //reference widgets redseekbar = (seekbar) findviewbyid(r.id.redseekbar); greenseekbar = (seekbar) findviewbyid(r.id.greenseekbar); blueseekbar = (seekbar) findviewbyid(r.id.blueseekbar); alphaseekbar = (seekbar) findviewbyid(r.id.alphaseekbar); colorview = (view) findviewbyid(r.id.colorview); colortextview = (textview) findviewbyid(r.id.colortextview); //listener redseekbar.setonseekbarchangelistener(this); greenseekbar.setonseekbarchangelistener(this); blueseekbar.setonseekbarchangelistener(this); alphaseekbar.setonseekbarchangelistener(this); } @override public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { int redvalue = redseekbar.getprogress(); int greenvalue = greenseekbar.getprogress(); int bluevalue = blueseekbar.getprogress(); int alphavalue = alphaseekbar.getprogress(); argb(alphavalue, redvalue, greenvalue, bluevalue); colorview.setbackgroundcolor(colorvalue); string rgbvalue = integer.tostring(progress); colortextview.settext(rgbvalue); } @override public void onstarttrackingtouch(seekbar seekbar) { } @override public void onstoptrackingtouch(seekbar seekbar){ } public static int argb (int alpha, int red, int green, int blue){ return colorvalue; }
}
your colorvalue
0!
replace argb(alphavalue, redvalue, greenvalue, bluevalue);
by colorvalue = argb(alphavalue, redvalue, greenvalue, bluevalue);
edit:
i realized now: argb
method nothing! don't make proper use of parameter!
replace by:
public int argb (int alpha, int red, int green, int blue) { return color.argb(alpha, red, green, blue); }
Comments
Post a Comment