07-17-2012 01:47 AM
I'm working in a Blackberry app (OS 5.0) and need to show recent tweets of the user.
I'm able to get the data from Twitter's end. Now after parsing the entities (hashtags, urls, user-mentions etc), I need to display them with separate formatting (color, bold etc). So I'm using different LabelFields for different parts of the tweet.
But LabelFields are by default block elements. How do I put those LabelFields inline, so that it looks like how it is shown in Twitter?
Solved! Go to Solution.
07-17-2012 07:30 AM
Blackberry Fields are always rectangular, so to get the formal you want you will have to overlap the Fields, which starts getting a bit complicated.
Instead I would suggest you create a single Field, and then override the paint() method to paint the text that you want. Then you can set the color and font, draw a bit of text, change the color, draw another bit of text, and so on. Sounds really complicated, but it is actually easier than you might think.
In this case however you might be better using a ListField, becuase you have rows. Each row can be painted in much the same way, and ListField is very efficient if you have loads of tweets to show.
Also, have a look here
for some other useful UI components and sample code.
07-17-2012 08:27 AM
Ok I'll try this.
Any suggestion on how to handle urls? If there is any url in the tweet, I need to navigate the user to that url on touch/trackball click. So I need to make the urls focusable, and detect touchEvent on the urls, like the native Blackberry Twitter application does.
07-17-2012 10:38 AM
Now that is a little complicated.
In which case you might like to consider using a RichTextField and not a ListField - then you get this for free. have a look at this too:
07-17-2012 10:49 AM
In fact, there is a field which was made specifically for this purpose - ActiveRichTextField. You can even navigate between various "regions" of this field and have different click reactions in different parts.