3

Im working on my mobile app, and trying to code it with nativescript, but Im having a problem I want to animate view of item, in listView ...

Here is my code so far:

let page = args.object;
 const radList = page.getViewById('myList');
 const item = radList.getItemAtIndex(0);
 const itemView = radList.getViewForItem(item);

But my itemView is always undefined, also I tried with getChildAt() method but it doesnt work... I dont want to use, itemDeleteAnimation because I want to use my own animation

Nick Iliev
  • 9,610
  • 3
  • 35
  • 89
Loki
  • 1,064
  • 2
  • 26
  • 55

1 Answers1

3

I think you are hitting a timing issue, which can be resolved by using setTimeout. Another possibility (if applicable) is to use the itemLoading event to get a reference to the view via ListViewEventData

Here is an example of both:

TypeScript

export function onRadLoaded(args) {
    const radList = <RadListView>args.object;

    setTimeout(() => {
        const item = radList.getItemAtIndex(0);
        const view = radList.getViewForItem(item);

        console.log(view);
    }, 300);
}

export function onItemLoading(args: ListViewEventData) {
    console.log("args.view: ", args.view);

    console.log("args.data: ", args.data);
    console.log("args.index: ", args.index);
}
Nick Iliev
  • 9,610
  • 3
  • 35
  • 89