Skip to content Skip to sidebar Skip to footer

Nativescript Code Behind - Add Gridlayout To Scrollview Dynamically

I am creating a dynamic GridLayout in Nativescript following the example on there page: https://docs.nativescript.org/ui/layouts/layout-containers It allows my to make a GridLayout

Solution 1:

You need to import from import { ScrollView } from 'ui/scroll-view';

and it's not addView, available public method is _addView

Solution 2:

So just as reference for anyone else in the future.

The _addView() method wouldn't throw any errors, however I couldn't get the scene to actually load or show anything.

If there is a way to load the _addView() correctly then more than happy fo someone to add that comment.

The playground for that method is below:

https://play.nativescript.org/?template=play-js&id=LlsHLd

The way I got it working is by doing the following:

const scrollView = require("tns-core-modules/ui/scroll-view").Scroll-View;
var scrollV = newscrollView();

(Dynamically load a gridlayout)
grid.addChild()
....

scroll.content = grid;
page.content = scroll;

Thanks everyone for the help.

Post a Comment for "Nativescript Code Behind - Add Gridlayout To Scrollview Dynamically"