【发布时间】:2016-03-18 19:15:34
【问题描述】:
我正在开发一个列表,我想通过将字体颜色显示为红色来突出显示某些行。这可能吗?
编辑: 好的,这是我的代码的简化版本:
Skin defListSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
List listHistory = new List<String>(defSkin);
// Here I set the general font color for the list
List.ListStyle listStyle = listHistory.getStyle();
listStyle.font = fontList;
listStyle.fontColorUnselected = Color.LIGHT_GRAY;
listHistory.setStyle(listStyle);
String[] items = new String[20];
// Example of item[]
// item[0]: "John 12"
// item[1]: "Amy -3" <-- I want certain lines to appear in red (e.g. those with negative numbers)
// Populate the list
listHistory.setItems(items);
// Drawing the list (actual draw happens in render() of course)
Table myTable = new Table();
myTable.add(listHistory);
stage.addActor(myTable);
【问题讨论】:
-
太含糊了 :) 给我们你尝试过的东西,也许是你想要达到的目标的屏幕截图。
-
你现在画的怎么样了?你有某种
List<String>。你可以做spriteBatch.setColor(..)。