---
title: "flex3 List组件内容自动换行支持"
author: "pgwcumt"
date: "2012-03-05T17:18:04Z"
tags: ["Flex", "List", "换行"]
categories: ["Web前端"]
slug: "flex3-list"
draft: false
lastmod: "2012-03-08T17:41:32Z"
id: 1440779
url: "https://pgwcumt.iteye.com/blog/1440779"
---

flex3中 List控件是一种显示垂直项目的列表，对于超出显示空间的内容，可以通过水平的或是垂直的滚动条进行查看；也可以通过重新渲染，使List的Item中的内容自动换行。

 

 

```
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="absolute">
	<mx:Model id="mystates">
		<states>
			<state label="Alabama Alabama Alabama Alabama Alabama Alabama Alabama Alabama"
				   data="AL"/>
			<state label="Alaska"
				   data="AK"/>
			<state label="Arizona"
				   data="AZ"/>
			<state label="Arkansas"
				   data="AR"/>
			<state label="California"
				   data="CA"/>
			<state label="Colorado"
				   data="CO"/>
			<state label="Connecticut"
				   data="CT"/>
		</states>
	</mx:Model>
	<mx:List id="listID"
			 x="300"
			 y="50"
			 width="200"
			 height="200"
			 fontSize="16"
			 horizontalScrollPolicy="off"
			 variableRowHeight="true"
			 dataProvider="{mystates.state}">
		<mx:itemRenderer>
			<mx:Component>
				<mx:Text text="{this.data.label}"
						 selectable=" true"/>
			</mx:Component>
		</mx:itemRenderer>
	</mx:List>
</mx:Application>
```