Search code examples
androidlistviewappceleratorappcelerator-titaniumappcelerator-alloy

alloy listView android - dynamic data disappears when scrolling


Created a basic listView to test it out. ios version works as intended. On a genymotion android emulator, when scrolling, the bound dynamic data gets overwritten with blanks/null. This can be demonstrated easily using this gist listed here on a generic alloy test app. Just add code to the respective index.* files. You'll need a recent version of moment.js in the /lib directory.

Why is it overwritten? I suspect it has something to do with how listView reuses components. How do I fix it?

Thanks.


Solution

  • In working through the problem, I found that the issue is the horizontal layout that you have applied to the .row class in your index.tss file. If you remove that layout, then your list view will behave as expected.

    Why is this happening? Well to be honest i'm not sure, but I have a guess. In the effort to minimize memory, listViews only render items that are visible on the screen. In this case when the item goes off screen, then when it becomes visible again, its possible that the layout isn't rendering properly due to conflicts with the other styles that are applied (and conflict) with your intended layout.