feat(autojs): list.on("item_bind")
This commit is contained in:
@@ -6,6 +6,7 @@ ui.layout(
|
||||
<vertical>
|
||||
<text id="name" textSize="16sp" textColor="#000000" text="姓名: {{name}}"/>
|
||||
<text id="age" textSize="16sp" textColor="#000000" text="年龄: {{age}}岁"/>
|
||||
<button id="deleteItem" text="删除"/>
|
||||
</vertical>
|
||||
</list>
|
||||
</frame>
|
||||
@@ -28,6 +29,14 @@ var items = [
|
||||
|
||||
ui.list.setDataSource(items);
|
||||
|
||||
ui.list.on("item_click", function(i, item, itemView, listView){
|
||||
ui.list.on("item_click", function(item, i, itemView, listView){
|
||||
toast("被点击的人名字为: " + item.name + ",年龄为: " + item.age);
|
||||
});
|
||||
});
|
||||
|
||||
ui.list.on("item_bind", function(itemView, itemHolder){
|
||||
itemView.deleteItem.on("click", function(){
|
||||
let item = itemHolder.item;
|
||||
toast("被删除的人名字为: " + item.name + ",年龄为: " + item.age);
|
||||
items.splice(itemHolder.position, 1);
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user