Nativescript : Select 来自 Listview 的级别
Nativescript : Select a level from Listview
当列表视图(即那个关卡)是 tapped.I 时,我想获得关卡文本 tapped.I 能够获得该关卡的索引 level.But 我无法获得关卡文本字段。
查看:
<Page loaded="loaded">
<GridLayout>
<ListView items="{{ categoryList }}" itemTap="brand">
<ListView.itemTemplate>
<Label text="{{ category }}" horizontalAlignment="left" verticalAlignment="center" />
</ListView.itemTemplate>
</ListView>
</GridLayout>
</Page>
Js控制器:
function getBrand() {
user.register();
}
exports.brand=function (args){
item=args.index;
//what to put here to be able to get the level text property
user.register(item);
}
已编辑:可以将tap监听器放到label里面,通过args
获取引用:
在XML中:
<ListView items="{{ categoryList }}">
<ListView.itemTemplate>
<Label text="{{ category }}" tap="brand"/>
</ListView.itemTemplate>
</ListView>
然后在 js 中:
exports.brand = function(args) {
item = args.object;
var text = item.text;
}
当列表视图(即那个关卡)是 tapped.I 时,我想获得关卡文本 tapped.I 能够获得该关卡的索引 level.But 我无法获得关卡文本字段。
查看:
<Page loaded="loaded">
<GridLayout>
<ListView items="{{ categoryList }}" itemTap="brand">
<ListView.itemTemplate>
<Label text="{{ category }}" horizontalAlignment="left" verticalAlignment="center" />
</ListView.itemTemplate>
</ListView>
</GridLayout>
</Page>
Js控制器:
function getBrand() {
user.register();
}
exports.brand=function (args){
item=args.index;
//what to put here to be able to get the level text property
user.register(item);
}
已编辑:可以将tap监听器放到label里面,通过args
获取引用:
在XML中:
<ListView items="{{ categoryList }}">
<ListView.itemTemplate>
<Label text="{{ category }}" tap="brand"/>
</ListView.itemTemplate>
</ListView>
然后在 js 中:
exports.brand = function(args) {
item = args.object;
var text = item.text;
}