labelField问

时间:2012-10-23 23:42:27

标签: flex flash-builder labelfield

大家好我有xml数据库如何拨打电话并在标签中显示? 我已经有了标签字段但我想在电话旁边拨打电话

怎么样?

这是我的鳕鱼

<s:List id="lst" x="73" y="197" width="295" height="214" change="lst_changeHandler(event)"
            dataProvider="{arr}" fontSize="30" fontWeight="bold" 
             textAlign="right">
        <s:labelField>RestaurantsKuwaiti</s:labelField>

http://www.mlfnt.com/lives6/13510357301.png

1 个答案:

答案 0 :(得分:0)

首先,您的xml不像列表:

   <RestaurantsKuwaiti>
   ...
   <RestaurantsOther>
   ...
I think it should be like:
   <Restaurants>
     <name>Kuwaiti</name>
   </Restaurants>
   <Restaurants>
     <name>Syria</name>
   </Restaurants>
   ...

使用labelFunction可以解决您的问题:

  <fx:Script>
    <![CDATA[
      import mx.collections.XMLListCollection;

      private var xml:XML = 
        <dataroot>
          <alldata>
            <ID>1</ID>
            <Main>2</Main>
            <RestaurantsKuwaiti>
              <phone>55555555</phone>
            </RestaurantsKuwaiti>
          </alldata>
        </dataroot>;

      [Bindable]
      private var dataList:XMLListCollection = new XMLListCollection(xml.alldata);

      private function labelFunc(item:Object):String {
        return item.RestaurantsKuwaiti.phone;
      }
    ]]>
  </fx:Script>

  <s:List dataProvider="{dataList}" labelFunction="labelFunc"/>

如上所述,“dataList”只有一个项目:“alldata”。