List控件

List.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*">
    
<!-- Model标签主要用于数据,Model定义的数据编译被转化为一般的ActionScript数据对像,
    可以用作数据绑定。不同的是,这些数据不可以被更改,没有明确的数据类型,可以是字符串,整型,XML数据等。 
-->
    
<mx:Model id="images">
        
<image>
            
<item label="图片1" data="C:MyProject lexProjectimages/1.gif"></item>
            
<item label="图片2" data="C:MyProject lexProjectimages/2.gif"></item>
            
<item label="图片3" data="C:MyProject lexProjectimages/3.gif"></item>
            
<item label="图片4" data="C:MyProject lexProjectimages/4.gif"></item>
        
</image>
    
</mx:Model>
    
<mx:List x="72" y="62" dataProvider="{images.item}" itemRenderer="ImageItem"></mx:List>
    
<!-- images.item包含了XML数据中所有节点为“item”的数据,并通过dataProvider属性将数据传递给List组件  -->
    
<!-- itemRenderer="ImageItem"表示用自定义的itemRenderer来代替默认的组件,ImageItem就是自定义的组件   -->
</mx:Application>
ImageItem.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="102" height="54">
    
<mx:Image width="39" height="41" source="{data.data}"/>
    
<mx:Button label="{data.label}" width="54" height="40"/>
    
<!-- flex通过data属性,将数据传递给itemRenderer的,在自定义的itemRenderer中,直接调用data对像的属性就可以了,但itemRenderer并不对数据进行有效的验证  -->
</mx:HBox>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值