加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 01:11:49 所属栏目:百科 来源:网络整理
导读:添加基本的界面元素 打开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(MyNew

添加基本的界面元素

打开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。


创建新的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”
如下图


在新的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

现在可以进行测试了

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读