Saturday 15 February 2014

java - Where disappeared the method TextView.getTextColor(Context context, TypedArray typedArray, int defStyle) in new Android 5.0? -



java - Where disappeared the method TextView.getTextColor(Context context, TypedArray typedArray, int defStyle) in new Android 5.0? -

after sdk updating android 5.0 disappeared method textview.gettextcolor(context context, typedarray typedarray, int defstyle). used method custom textview (for int colorid definition xml). how determineint color id xml?

here sample code getting color textview:

textview tv = (textview) findviewbyid(r.id.yourcomponentid); int tv_color = tv.gettextcolors().getdefaultcolor();

or can color normal text this:

textview tv = (textview) findviewbyid(r.id.yourcomponentid); int tv_color = tv.getcurrenttextcolor();

in case of using first example, can color various states using

textview tv = (textview) findviewbyid(r.id.yourcomponentid); colorstatelist colorstatelist = tv.gettextcolors(); int tv_color colorstatelist.getcolorforstate(states, failcolor);

hope helps.

reference: getcolorforstate

java android textview android-5.0-lollipop

No comments:

Post a Comment