diff --git a/tests/app/ui/segmented-bar/segmented-bar-tests.ts b/tests/app/ui/segmented-bar/segmented-bar-tests.ts index 9660b7e24..457822679 100644 --- a/tests/app/ui/segmented-bar/segmented-bar-tests.ts +++ b/tests/app/ui/segmented-bar/segmented-bar-tests.ts @@ -270,3 +270,14 @@ export var testSelectedIndexChangedIsRaisedCorrectlyIfItemsNotBound = function ( TKUnit.assertEqual(newSelectedIndex, 1); }); } + +export function test_SettingNumberAsTitleFromXML_DoesNotThrow() { + let segmentedBar = new segmentedBarModule.SegmentedBar(); + let item = new segmentedBarModule.SegmentedBarItem(); + (item).title = 1; + segmentedBar.items = [item]; + + buildUIAndRunTest(segmentedBar, function (views: Array) { + TKUnit.assertEqual(item.title, "1"); + }); +} diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts index 927c891f9..91ac60ef6 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar-common.ts @@ -28,8 +28,9 @@ export class SegmentedBarItem extends bindable.Bindable implements definition.Se } set title(value: string) { - if (this._title !== value) { - this._title = value; + let strValue = (value !== null && value !== undefined) ? value.toString() : ""; + if (this._title !== strValue) { + this._title = strValue; this._update(); } } diff --git a/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts b/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts index 03e1cb839..eef237bb0 100644 --- a/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts +++ b/tns-core-modules/ui/segmented-bar/segmented-bar.android.ts @@ -110,7 +110,7 @@ export class SegmentedBarItem extends common.SegmentedBarItem { var tabIndex = this._parent.items.indexOf(this); var titleTextViewId = 16908310; // http://developer.android.com/reference/android/R.id.html#title var titleTextView = this._parent.android.getTabWidget().getChildAt(tabIndex).findViewById(titleTextViewId); - titleTextView.setText(this.title || ""); + titleTextView.setText(this.title + ""); } } } @@ -162,7 +162,7 @@ export class SegmentedBar extends common.SegmentedBar { tabItem._parent = this; var tab = this.android.newTabSpec(this.getValidIndex(index) + ""); - tab.setIndicator(tabItem.title || ""); + tab.setIndicator(tabItem.title + ""); let that = this; tab.setContent(new android.widget.TabHost.TabContentFactory({ createTabContent: function (tag: string): android.view.View {