Changing Nativescript Listview `onItemTap` background color?


#1

I have a ListView :

enter image description here

This is the markup :

<ListView   [items]="items " class="list-group" (itemTap)="onItemTap($event)"  >
    <ng-template  let-item="item" let-i="index" let-odd="odd" let-even="even"  >
        <Label [text]='item._name' class="row list-group-item" [id]="'lbl' + i"></Label>
    </ng-template>
</ListView>

However - when I click an item - nothing happens with the background-color. ( i’m expecting to have some indication of being tapped).

I’ve already have this code (which does execute when I tap )

  onItemTap($event)
    {
        var lbl = <Label>$event.view.getViewById("lbl" + $event.index);
        console.log(lbl.text);
    }

BTW

If it was a button instead of label - I could’ve done :

.row:highlighted{
    background-color:#00A3FF;
}

But as you can see - I’m using Label.

Question
How can I highlight the label’s background color when tapped ?


#2

for changes on List view to be applied, you need to refresh your Listview after the changes. something like

var listView = page.getViewById("listview");
listView.refresh();