Application Tool Kit

Text color on SingleLineWidget when single tap

Hello,

When i singleTap a word on SingleLineWidget , the selected word will change its color.

But if I use the setTextColor method to set the SingleLineWidget 's color , then singleTap to select a word ,the selected word will not change its color.

How can I solve this problem?

Thank you.


Dear Zheng,


normally, when changing the color using the "setTextColor", it sets the color to all the text (normam and selected).


Otherwise, you can try using the void setTextColors(ColorStateList colors) function. With this latter one, you can set the color for "normal" (EMPTY_STATE_SET) and "selected" (SELECTED_STATE_SET) text


Otherwise, it uses the color set in the SingleLineWidgetSample\src\main\res\layout\activity_main.xml file.


Best regards,


Olivier


1 person likes this

solve this problem with the function setTextColors();

private ColorStateList createColorStateList(int selected, int normal) {
int[] colors = new int[] {selected, normal};
int[][] states = new int[2][];
states[0] = new int[] { android.R.attr.state_selected};
states[1] = new int[] {};
ColorStateList colorList = new ColorStateList(states, colors);
return colorList;
}
Login or Signup to post a comment