Kuix教程2 - 动态加载数据

下面是一个通过设置DataProvider影响界面的例子,用按钮控制一个当选框的值。
XML界面
<screen>
    <_title>%DYNAMIC_DISPLAY%</_title>
    <container style="layout:inlinelayout(false,fill);align:center">
        <text style="padding: 0 0 15 0">%PLATFORM_NAME(@{platformName})%</text>
        <container style="layout:gridlayout(2,1)">
            <button onAction="btn_female" shortcuts="1">%FEMALE_BTN%</button>
            <button onAction="btn_male" shortcuts="2">%MALE_BTN%</button>
        </container>
        <text>%GENDER(@{gender})%</text>
        
        <radioGroup onChange="">
		    <_value>@{gender}</_value>
		    <radioButton value="F" enabled="true">female</radioButton>
		    <radioButton value="M" enabled="true">male</radioButton>
		</radioGroup>
    </container>

    <screenFirstMenu onAction="back">返u22238 </screenFirstMenu>
    <screenSecondMenu>
        %MORE%
        <menuPopup>
            <menuItem onAction="about">
                %ABOUT%
            </menuItem>
            <menuItem onAction="exitConfirm">
                %EXIT%
            </menuItem>
        </menuPopup>
    </screenSecondMenu>
</screen> 
 

事件处理:
	public boolean onMessage(Object identifier, Object[] arg1) {
	    if ("back".equals(identifier)) {
	        // remove the current frame from the framehandler stack
	        Kuix.getFrameHandler().removeFrame(this);

	        // and display the main screen
	        Kuix.getFrameHandler().getTopFrame().onAdded();

	        // do not propagate the message through the rest of the frame stack
	        return false;
	    } else if ("btn_female".equals(identifier)) {
	        // use the data provider to set its value
	        dataProvider.setGender("F");
	    } else if ("btn_male".equals(identifier)) {
	        // use the data provider to set its value
	        dataProvider.setGender("M");
	    } 

	    // let the next frames in the stack, process the message
	    return true;
	}
 运行结果:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值