我在布局中为列表中的各个项目定义了一个imageview,并将它们设置为不可见。当我点击一个按钮时,它们将会显示,但我无法采取此行动。我想达到这个效果。这是我的代码:
//file:list_view_test.jade
Alloy
Window#win
Button#btn(title = "Show" onClick = "show_the_image_view")
ListView#list_view(defaultItemTemplate = "list_style")
Templates
ItemTemplate(name = "list_style")
View#item_view(bindId = "bind_item_view")
ImageView#image_view(bindId = "bind_image_view")
ListSection
ListItem(bind_item_view:backgroundImage = "/images/backgroundImage_1.png"
bind_image_view:image = "/images/unchecked_image.png")
ListItem(bind_item_view:backgroundImage = "/images/backgroundImage_2.png"
bind_image_view:image = "/images/unchecked_image.png")
//file:list_view_test.stss
#item_view{
width:100%;
height:10%
}
#image_view{
top:0;
left:0;
width:20%;
height:20%;
visible:false
}
//file:list_view_test.coffee
show_the_image_view = ->
if "Show" == $.btn.getTitle()
$.btn.setTitle("Hide")
//$.image_view.setVisible(true) (this code had been commented, cause it's wrong)
else if "Hide" == $.btn.getTitle()
$.btn.setTitle("Show")
//$.image_view.setVisible(false) (this code had been commented, cause it's wrong)
$.list_view.addEventListener('itemclick', = (e) ->
if e.itemIndex == 0
//$.image_view.setImage('/images/checked_image.png') (this code had been commented, cause it's wrong)
else if e.itemIndex == 1
//$.image_view.setImage('/images/checked_image.png') (this code had been commented, cause it's wrong)
有没有人有一个很好的方法来解决这个问题?