如何在钛合金的标签组中重新加载标签 [英] How to reload the tab in tab group in titanium alloy

查看:147
本文介绍了如何在钛合金的标签组中重新加载标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标签组中有三个标签.一个选项卡用于更改语言.如果用户更改语言,我应该需要更改所有选项卡的选定语言.我的标签组代码如下,

I have three tabs in my tab group. One tab is for change language. If user changes the language I should need to change the selected language for all the tabs. my tab group code is as follows,

<Alloy>
  <TabGroup id="myTabGrp"> //Tabgroup Added
    <Tab id="one">
        <Window class="container">
            <Label>This is the Home View</Label>
        </Window>
    </Tab>

    <Tab id="two">
        <Window class="container" id="winTwo">
            <Label>This is the second View</Label>
        </Window>
    </Tab>

    <Tab id="three">
        <Window class="container">
            <Button onClick="saveLang">Proceed</Button>
        </Window>
     </Tab>
  </TabGroup>
</Alloy>

所有ui文本都从数据库中丢失.因此,我该如何重新加载tab3中继续"按钮的时钟上的选项卡.

All the ui text is losing from database. So How can I reload the tab on clock of proceed button in tab3.

我尝试了以下代码,

function saveLang() {
  $.myTabGrp.setActiveTab($.two);
}
$.winTwo.addEventListener('focus',function(e) { 
   // How can I reload the tab2 here....
alert('focus');
});

如果我尝试下面的代码,一切都可以正常工作,但是,加载它花费的时间太长,将使其结构化3秒钟,然后加载所需的输出.我需要避免较长的加载时间.

If I try the following code everything is working fine but, It is taking too long to load it will struct for 3 sec and then loading the required output. I need to avoid the long loading time.

var homeWindow = Alloy.createController('index').getView();
homeWindow.open({transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT});

关于如何以更少的加载时间重新加载选项卡的任何建议.

Any suggestions that how can we reload the tab with less loading time..

推荐答案

您问题的某些部分在此处(如何从一个翻页到钛的另一页?).

当您切换到选项卡2或 winTwo 或打开tabGroup时,将调用一些函数来更新窗口UI.也许您会在index.js中看到类似以下内容的内容:

When you switch to tab two or winTwo or when you open tabGroup, there would be some function which you call to update your window UI. Maybe you will have something like following in index.js :

$.myTabGrp.open();
updateWin1();
updateWin2();
updateWin3();

function updateWin1() {
  var value = "Win1"; //fetched from local db
  $.win1Label.text = value;
}

function updateWin2() {
  var value = "Win2"; //fetched from local db
  $.win2Label.text = value;
}

function updateWin3() {
  var value = "Win3"; //fetched from local db
  $.win3Label.text = value;
}

现在在您的 winTwo 的焦点EventListener中,调用updateWin2方法(如下所示):

Now in your winTwo's focus EventListener call the updateWin2 method ( like following ):

$.winTwo.addEventListener('focus',function(e) { 
  //Reloaded
  updateWin2();
});

注意:根据您的要求,您可以在方法updateWin2()中进行任何复杂的UI操作.

Note : You can have any complex amount of UI manipulation in the method updateWin2(), according to your requirement.

PS:如果您使用的是合金模型和集合概念,则应尝试合金数据绑定.

P.S : If you are using Alloy models and collection concept, you should try Alloy Data Binding.

这篇关于如何在钛合金的标签组中重新加载标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆