【问题标题】:How to change an action bar title text when moving from one tab to another tabs in nativescript在nativescript中从一个选项卡移动到另一个选项卡时如何更改操作栏标题文本
【发布时间】:2017-06-06 07:13:55
【问题描述】:
  • 第一次加载这个 mainactivity 页面时,它正在加载 第三个标签页操作栏文本。

  • 我需要加载基于点击标签的操作栏文本。

  • 例如:当我单击第二个选项卡时,意味着第二个选项卡操作栏有 获得触发。

ma​​in.activity.html:

<ActionBar title="MainActivity" class="action-bar">

</ActionBar>


<TabView selectedIndex="0" (selectedIndexChange)="onIndexChanged($event)"  iosIconRenderingMode="alwaysTemplate" selectedTabTextColor="blue" sdkExampleTitle sdkToggleNavButton>
<TabView iosIconRenderingMode="alwaysOriginal"></TabView>

<StackLayout *tabItem="{title: 'First Tab',iconSource:'res://store'}" >
<first-page></first-page>
</StackLayout>

<StackLayout *tabItem="{title: 'Second Tab',iconSource:'res://myapps'}" >
<second-page></second-page>
</StackLayout>

<StackLayout *tabItem="{title: 'Third Tab',iconSource:'res://home'}" >
<third-page></third-page>
</StackLayout>

</TabView>

ma​​in.activity.ts:

public onIndexChanged(args) {
        let tabView = <TabView>args.object;
        console.log("Selected index changed! New inxed: " + tabView.selectedIndex);
    }

【问题讨论】:

    标签: angular2-routing nativescript angular2-nativescript


    【解决方案1】:

    对于每个标签位置,我们需要添加标签索引并添加相应页面的标题。

       <ActionBar *ngIf="tabIndex == 1" title="My Apps" color="black"> </ActionBar>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多