public Spannable[] itemsToColoredText() { // TODO(hal): Generalize this so that different items could have different // colors and even fonts and sizes int size = items.size(); int displayTextSize = textSize; Spannable[] objects = new Spannable[size]; for (int i = 1; i <= size; i++) { // Note that the ListPicker and otherPickers pickers convert Yail lists to string by calling // YailList.ToStringArray. // ListView however, does the string conversion via the adapter, so we must ensure // that the adapter uses YailListElementToSring String itemString = YailList.YailListElementToString(items.get(i)); // Is there a more efficient way to do conversion to spannable strings that does not // need to allocate new objects? Spannable chars = new SpannableString(itemString); chars.setSpan(new ForegroundColorSpan(textColor), 0, chars.length(), 0); if (!container.$form().getCompatibilityMode()) { displayTextSize = (int) (textSize * container.$form().deviceDensity()); } chars.setSpan(new AbsoluteSizeSpan(displayTextSize), 0, chars.length(), 0); objects[i - 1] = chars; } return objects; }