Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7496] Ti API: UI - numbers displayed as float on Android and integer on iOS

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T19:43:12.000+0000
Affected Version/sRelease 1.8.1
Fix Version/sn/a
ComponentsTiAPI
Labelsparity
ReporterPaul Dowsett
AssigneeIngo Muschenetz
Created2012-02-01T05:05:42.000+0000
Updated2020-01-09T19:43:12.000+0000

Description

Problem

For consistency and parity, we need to decide how we should display numbers by default in the UI across all platforms. For example, the toString() method has always been necessary on Android when displaying a Number type that is an integer in a Label, to prevent it displaying as a float. iOS, on the other hand, displays it as an integer. We should test all UI modules that are able to display text (for example, AlertDialog, TextField, OptionDialog) with an aim of making them consistent.

Test case

The code below returns these results: * Android displays 324.0 * iOS displays 324 Note that the Ti.API.info() statement confirms that label.text is a Number type on Android and iOS.
var win = Ti.UI.createWindow({
	backgroundColor: 'white',
	fullscreen: false
});

var bigNumber = 324;
var label = Ti.UI.createLabel({
	backgroundColor:'green',
	text: bigNumber,
	textAlign: 'center'
});

win.add(label);
win.open();
Ti.API.info('Label.text is type: '+typeof(label.text));

Comments

  1. Shannon Hicks 2013-04-09

    It would be great if we can wrap up one of the last major parity issues in 3.2
  2. Bryan Hughes 2013-04-09

    Few quick comments. There is no typeof method, it's just an operator. Wrapping parens around it works fine, but it's superfluous. It's like doing
       3 + (4)
       
    It's better to do typeof label.text instead of typeof(label.txt) As far as the point at hand, I wonder if this is actually a parity bug in our code, or just a difference in V8 and JSCore.
  3. Alan Hutton 2020-01-09

    It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source