【问题标题】:How to reload the tab in tab group in titanium alloy如何重新加载钛合金标签组中的标签
【发布时间】:2023-03-03 00:45:01
【问题描述】:

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

<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中继续按钮的时钟选项卡。

我尝试了以下代码,

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

如果我尝试以下代码,一切正常,但是加载时间太长,它将 struct 3 秒,然后加载所需的输出。我需要避免过长的加载时间。

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

关于我们如何以更少的加载时间重新加载标签的任何建议..

【问题讨论】:

    标签: tabs titanium titanium-mobile appcelerator titanium-alloy


    【解决方案1】:

    您的部分问题已回答here ( how to redirect from one page to tab in another page in titanium? )

    当您切换到标签二或 winTwo 或打开 tabGroup 时,您会调用一些函数来更新窗口 UI。也许你会在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 方法(如下所示):

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

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

    P.S : 如果你使用的是合金模型和收藏概念,你应该试试Alloy Data Binding

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-19
      相关资源
      最近更新 更多