我无法弄清楚如何获得Button的文本的当前颜色.我知道它可能是这个,但不能完全弄清楚参数.
public static int getTextColor (Context context, TypedArray attrs, int def)...
Run Code Online (Sandbox Code Playgroud)
基本上我试图这样做
if(text is RED)
{make text BLACK}
else
{make text RED}
Run Code Online (Sandbox Code Playgroud)
我知道如何设置文本颜色.
AjO*_*ire 12
试试这个
ColorStateList mList = mButton.getTextColors();
int color = mList.getDefaultColor();
switch(color)
{
case Color.RED:
mButton.setTextColor(Color.BLACK);
break;
case Color.BLACK:
mButton.setTextColor(Color.RED);
break;
}
Run Code Online (Sandbox Code Playgroud)