Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 48
Registered: ‎06-02-2013
My Device: 9780
My Carrier: MTS UKR
Accepted Solution

Another problem with AutoText

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/autotext/AutoText.html#add(...

String p = "1111";
String t = "2222";
AutoText autoText = AutoText.getAutoText();
autoText.add(t, p, AutoText.SMART_CASE, Locale.LOCALE_en);

 When I put this code into my project, I keep getting an error message:

"The method add(String, String, int, Locale) in the type AutoText is not applicable for the arguments (String, String, int, int)"

 

I don't get this error's nature. Well, the API documentation tells me Locale IS integer. What am I missing?

Developer
Posts: 121
Registered: ‎05-31-2012
My Device: 9900
My Carrier: Airtel

Re: Another problem with AutoText

Rebelllious its again related to basic JAVA concept.

 

Here is the solution, try this--

 

String p = "1111";
        String t = "2222";
        AutoText autoText = AutoText.getAutoText();
        autoText.add(t, p, AutoText.SMART_CASE, Locale.get(Locale.LOCALE_en));

 

If you look at the declaration of add method, You can easily see that it requires a Locale instance.

public abstract Object add(String replacedString,
                           String replacementStringPattern,
                           int replacementCase,
                           Locale locale)
Rishikesh Singh
Developer
Posts: 48
Registered: ‎06-02-2013
My Device: 9780
My Carrier: MTS UKR

Re: Another problem with AutoText

I will give it a try.

Meanwhile, does this mean I am missing to somehow initialize Locale?

Developer
Posts: 121
Registered: ‎05-31-2012
My Device: 9900
My Carrier: Airtel

Re: Another problem with AutoText

Actually You were passing Locale.LOCALE_en where you suppose to pass an Locale instance.

 

You can get Locale instance by-  Locale locale = Locale.get(Locale.LOCALE_en);

 

So your call will change to this--

autoText.add(t, p, AutoText.SMART_CASE, Locale.get(Locale.LOCALE_en));

 

Thanks.

Rishikesh Singh