无法更改列表视图中所选项目的背景颜色。
我试图理解这一点。但解决方案是有角度的,我没有得到如何在JavaScript中使用它。
onItemTap: function (args) {
console.log('Item with index: ' + args.index + ' tapped');
args.object.backgroundColor = "#3489db";
},
在这里我可以改变完整列表视图的背景。
游乐场样本。 https://play.nativescript.org/?template=play-js&id=KZeq3j
我只想要选择的项目来改变它的背景。
我为你更新了游乐场here。 args.object为您提供listview本身。
onItemTap: function (args) {
for (var i = 0; i < this.countries.length; i++) {
this.countries[i].bgColor = "#FFFFFF";
}
console.log(this.countries[args.index])
this.countries[args.index].bgColor = "#3489db";
args.object.refresh();
},