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: 46
Registered: ‎06-02-2013
My Device: 9780
My Carrier: MTS UKR
Accepted Solution

Problem with AutoText adding

I still don't get the way I shall use it:

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

 

String p = "11111111";
String t = "22222222";
AutoText.add(t, p, SMART_CASE, LOCALE_en);

 This gives me error "Cannot make a static reference to the non-static method add(String, String, int, Locale) from the type AutoText".

It must really be something I miss being a novice in Java...

Can anyone help me get it running?

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

Re: Problem with AutoText adding

Rebelllious You are right, it is related to basic JAVA concept.

 

You need a instance of AutoText, to call add method.

 

Try this-

 

1. Get the instance of AutoText-

AutoText autoText = AutoText.getAutoText();

 

2. Call add method on this instance-

autoText.add(t, p, SMART_CASE, LOCALE_en);

 

Thanks.

 

 

Rishikesh Singh
Developer
Posts: 46
Registered: ‎06-02-2013
My Device: 9780
My Carrier: MTS UKR

Re: Problem with AutoText adding

Thanks a lot. This was the way to use it!

But this led me to another problem  - nullPointerException. Though it is not related to this topic.

Once again thanks.