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
Developer
Iyenemi_Tyger
Posts: 132
Registered: ‎10-25-2011
My Device: Tour 9630
Accepted Solution

activeautotexteditfield url opening native browser

Hello and good day everyone ,
Please i have developed a custom listfield just like twitter and I used activeautotexteditfield to display the messages , now some of this messages will definately have urls , I want these urls to be clickable , once clicked it should open the links in the native browser , I know about patternrepository and stringpatterns how do i get the regular expression pattern that will match urls in this field , thanks
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: activeautotexteditfield url opening native browser

I think normal things like http://,,,, will work in that Field.  Is that all you need?

Please use plain text.
Developer
Iyenemi_Tyger
Posts: 132
Registered: ‎10-25-2011
My Device: Tour 9630

Re: activeautotexteditfield url opening native browser

Capture.PNG

This screen is a scrollable verticalfieldmanager that holds the activerichtextfield , i am using a custom tablerowmanager to draw the components , however the links should be focusable with custom background colors , how can i achieve that ? , also how do i create click events for these hyperlinks , thanks peter.

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: activeautotexteditfield url opening native browser

"i am using a custom tablerowmanager"

 

I am betting this manager actually uses ListField.  This approach means that the Fields in the Row are only used for layout and painting, they are not used in the actually screen itself.

 

If you want focusable and selectable links in this case you will have to remove the ListField and add the Rows to a real Manager. 

Please use plain text.
Developer
Iyenemi_Tyger
Posts: 132
Registered: ‎10-25-2011
My Device: Tour 9630

Re: activeautotexteditfield url opening native browser

Yes it uses a listfield but with the tablerowmanager that's the only way I can layout custom components , please I ask r u saying I should develop a custom manager that will behave like a listfield ? , if so hw do I go about it ? , thanks peter
Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: activeautotexteditfield url opening native browser

"please I ask r u saying I should develop a custom manager that will behave like a listfield"

 

Sort of.  Exactly what you need will to do will depend on your requirement.

 

But the point here is that ListField just uses these Fields to 'paint' and nothing else.  So you need to actually use these Fields on your Screen. 

 

I think you might be able to get away with just adding the Rows to a VerticalFieldManager.  Then you will have to move the background processing processing code from the drawListRow into the paintBackground for the Row.  Give this a try and see how it goes.

 

But you will loose functionality like the performance (which may be quite bad if you have a large number of Fields) and the ability to easily determine the selected row.  If these are important, you might be better to remove the Link functinoality and provide a detail screen for each row that does use an ActiveField. 

 

So short answer is I don't know what the best solution for you is.

 

But please don't post your code here and ask me or anyone else to tell you what the best answer is.  It will be too complicated to understand easily and we don't know your requirements.  So think about it yourself, have a go at something and see what happens.

 

Here is more on writing your own manager:

 

http://supportforums.blackberry.com/t5/Java-Development/How-to-Extend-Manager/ta-p/446749

 

This is the standard link, but I don't think this is easy to understand:

http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

Please use plain text.
Developer
Iyenemi_Tyger
Posts: 132
Registered: ‎10-25-2011
My Device: Tour 9630

Re: activeautotexteditfield url opening native browser

Thanks peter , the truth is the field is much more like a twitter feed , we are going to be having a whole lot of messages as posts from different users , i think this should be possible because twitter uses the same thing .i really need a roadpath to achieve this .

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: activeautotexteditfield url opening native browser

[ Edited ]

Twitter was written by RIM, so they know how to write this sort of stuff and do it optimally.  I imagine there are quite few lines of code involved.

 

As a start, just add the Row Field to a VFM as I suggested.  Take it step at a time from there, fixing the things that are broken.

 

I would start with a single 'Row' that you can easily recreate.  Then duplicate it to add additional Rows.  When you have this working for multiple screens of data, then start looking and getting real data in. 

Please use plain text.
Developer
Iyenemi_Tyger
Posts: 132
Registered: ‎10-25-2011
My Device: Tour 9630

Re: activeautotexteditfield url opening native browser

ok i will try that thanks peter , i will keep you posted as i go along 

Please use plain text.
Developer
Iyenemi_Tyger
Posts: 132
Registered: ‎10-25-2011
My Device: Tour 9630

Re: activeautotexteditfield url opening native browser

Thanks peter , 

It did work the way you suggested i added the tablerowmanager directly to the scrollable verticalfieldmanager  and the hyperlinks are now showing ,however i still face an issue which is the activerichtextfield text contensts they do not align properly or do not show completely like the way twitter feeds will show i have tried modifying the sublayout parameters for the field in my tablerowmanager and also added a layout for my activerichtextfield but i still face the same issue , i will really need your help on this peter any idea why it would behave like that ?, i have attached a picture to show my text aligning problem ,  would love it to display all the contents of the text and properly aligned , thanks peter.

Capture2.PNG

Please use plain text.