Hi!
Im trying to update a listview which I dynamiclly populate every now and then. Since I can't remove item by item I remove the whole list and add it again but this fails for some reason.
If I add the list using list.addTo('layout') it appreas just fine but can't later be located using getNativeElementById. If I user layout.addChild(list) I can later pickit up with getNativeElementById but for some reason when I user addChild the list isn't shown on the screen.
The following code shows the problem. Just create a standard NativeUI Reload demo project and replace the counterButtonClicked() with the following code.
function counterButtonClicked()
{
// Remove listView
var listView = document.getNativeElementById('myList');
var listViewParent = document.getNativeElementById('mainLayout');
if (listView) {
mosync.rlog('found one');
listViewParent.removeChild('myList');
mosync.rlog('removed'); // never get's here if I use addTo
}
// Create new list
var lv = mosync.nativeui.create('ListView', 'myList', {
width: -1,
height: -1
});
mosync.rlog('created');
// using addTo really adds the list to the layout
// but fails on the second run when I try to remove it
lv.addTo('mainLayout');
// using addChild instead doesn't visually add the list
// to the layout (for some reason) but the code for
// finding and removing the list works
// listViewParent.addChild('myList');
/*
var lvi = mosync.nativeui.create('ListViewItem', 'lvi1', { text: new Date().getSeconds() });
lvi.addTo('myList');
*/
}I've been trying things the whole weekend but just can't get it to work, help please :)
-Fredrik