用Flex开发移动应用(2)---- 添加“Hello World”

添加基本的界面元素

打开HelloWorldView.mxml,在</s:View> 前加入以下代码

<s:VGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">       
    <s:Label text="Hello, World!"/>
    <s:Button label="Continue" click="navigator.pushView(MyNewView)" styleName="next"/>   
</s:VGroup>


添加之后代码如图所示。在容器VGroup中,有一个label,文字是“Hello、World”,还有一个按钮,文字是“Contiune”,当按钮按下后,将出现一个新的View。Code to display the 'Hello World!' text on the screen


创建新的View
1、File > New > MXML Component,显示New MXML Component对话框
2、确认Source Folder是“HelloWorld/src”
3、Package输入“views”
4、Name输入“MyNewView”
5、Layout为None
6、Based on选择“spark.components.View”
如下图
Creating the MyNewView view


在新的View中设定UI元素
1、打开MyNewView.xml
2、同样,在</s:View>之前,加入以下代码

<s:VGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">
    <s:Label text="Success!" />
    <s:Button label="Back" click="navigator.popView()" styleName="back" />
</s:VGroup>


以下是最终的代码。在这个View里,有一个label,文本是Success,一个文字为Back的按钮。其代码将导致回到前一个View

Code to display the "Success!" text on the second screen


现在可以进行测试了



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值