Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:TextField.setString() may throw an IllegalArgumentException in Series 40 2nd Edition devices if TextField.DECIMAL is used (Known Issue)

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.


Article Metadata
CompatibilityArticle
Created: User:Technical writer 1 (07 Feb 2008)
Last edited: hamishwillee (19 Nov 2013)


Contents

Overview

TextField.setString(Double.toString(Math.PI)) throws IllegalArgumentException in Series 40 2nd Edition devices.

Description

TextField.setString(Double.toString(Math.PI)) throws IllegalArgumentException in Series 40 2nd Edition devices. This appears to be because maximum amount of decimal digits is exceeded: if there are more than 8 decimal digits after the decimal point, the defined exception will be thrown. Double.toString(Math.PI) returns a String of 17 characters (15 digits).

How to reproduce

Try this:

 TextField txt;
..
txt = new TextField("Value:", "", 20, TextField.DECIMAL);
txt.setString(Double.toString(Math.PI));

Or this:

 TextField txt;
..
txt = new TextField("Value:", "", 20, TextField.DECIMAL);
textField.setString("3.141592653");

Solution

Avoid reading more than 8 digits or use String.substring(int beginIndex, int endIndex) for shortening the String or use TextField of type ANY.

This page was last modified on 19 November 2013, at 06:38.
55 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×