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
Contributor
handyway2011
Posts: 35
Registered: ‎02-02-2012
My Device: 9300
Accepted Solution

Selectable Table/ list for OS 6

Hi,

I'm working with Blackberry OS 6, and I would like to do a list that has both text and an icons. I want to manage the table, so  when one of the items is clicked  the app will bring me to another screen.

I've been looking in the UI Guideline 6.0 but I can't guess how to do it.

I've read this "Use theTableView

class to create an interactive rich list with text and icons" but I can't find the way.

Thanks

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Selectable Table/ list for OS 6

as i already said, objectlistfield has the limitation that the whole row is selected. if that does not bother you it does what you want.
there are several samples, both in the samples apps and on the forums.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
handyway2011
Posts: 35
Registered: ‎02-02-2012
My Device: 9300

Re: Selectable Table/ list for OS 6

Thanks again Simon.

I've been having a look in older messages, and I've found this one:

 

http://supportforums.blackberry.com/t5/Java-Development/ObjectListField-Sample-with-rows-of-image-mu...

 

As I can see there, if my device is not a touchscreen device, its possible to use ObjectListField?

Thanks you.

Contributor
handyway2011
Posts: 35
Registered: ‎02-02-2012
My Device: 9300

Re: Selectable Table/ list for OS 6

Sorry again...

I'm quite lost...

 

I've been searching in internet and after finding the code below, I've found this one:

 

http://davidjhinson.wordpress.com/2010/02/26/simple-list-ui-using-the-blackberry-sdk/

 

I understand more or less what's doing there and the example's screen is very simmilar to mine, but I don't how to handle the row events.

 

I mean, how can I know wich row is selected? (I would like to go to another page depending on where the user has clicked. Following the example of the sample code, if the user clicks Friends I would like to go to a screen and if it clicks on me to another).

 

Any help would be gratefull...

 

Thank you!

 

Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011
My Device: Bold 9900

Re: Selectable Table/ list for OS 6

I used a custom ListField but 

getSelectedIndex  will return the index of the currently selected row.

 

Here is a sample:

 

public class CustomListField extends ObjectListField {

 

   public boolean navigationClick(int status, int time){

            Object o = this.callback.get(this, getSelectedIndex());

            DetailScreen screen = new DetailScreen(o);

           UiApplication.getUiApplication().pushScreen(screen);

   }

}

Contributor
handyway2011
Posts: 35
Registered: ‎02-02-2012
My Device: 9300

Re: Selectable Table/ list for OS 6

Thank you very much!

Finally I decided to use ListStyleButtonField, as here

https://bdsc.webapps.blackberry.com/java/documentation/ww_java_uinavigation/Advanced_UI_components_a...

because was much more easy for me, and was enought to achieve my needs! (A screen which looks like a List, where buttons can have both, picture and text.

However, thank you both for your help!

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Selectable Table/ list for OS 6

which is basically a listfield. i still suggest that you take a look at the listfield, just to understand how it works, as it would have given you the exact same UI.
copying the code from the sample is a lot easier, of course, but understanding it may still be important.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
handyway2011
Posts: 35
Registered: ‎02-02-2012
My Device: 9300

Re: Selectable Table/ list for OS 6

Thanks for your advice, I will try with listfield later on. I'm quite begginer with Blackberry. Does ObjectListField give me any advantage comparing to ListStyleButtonField?
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Selectable Table/ list for OS 6

ObjectListField is very efficient - it is, after all, just a field, not a manager. This comes into play if you want to display hundreds of rows - then the slow down of other solutions becomes noticeable. ListStyleButtonSet 

 

There is, however, another huge benefit of using ObjectListField: it forces you to learn to draw the contents yourself (drawListRow) which introduces you to the concept of UI customization on BlackBerry. By starting small, you are getting yourself prepared to the eventual overriding of paint methods in other fields/managers (or, if you extend Field, like ListStyleButtonField does, implementing paint from scratch). Doubly important if you are just beginning.

 

If you go that route, however, don't take ListStyleButtonField as the first example - it is way too complicated. Go through simpler examples of using Graphics, then, once you understand them, go back and observe how it is done in ListStyleButtonField.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!