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
Trusted Contributor
jppedroso
Posts: 119
Registered: ‎04-29-2010
My Device: Curve 8520
My Carrier: TMN
Accepted Solution

focus on top of screen

 

Hi,

 

I'm a rookie on blackberry development.

I have a screen that when it loads, the focus is on a button on the bottom of the screen, not showing the top of the screen. That's because the screen content is bigger than the Curve screen.

How can I put visible the top of the screen?

 

Here's the code:

 

public ptnItem(xItem item)

{

super();


String sDescTratada = item.getDescription();

LabelField title = new LabelField(item.getTitle());

LabelField desc = new LabelField(sDescTratada);

LabelField data = new LabelField(item.getPubDate());

VerticalFieldManager vfmA = new VerticalFieldManager(Manager.VERTICAL_SCROLL);

vfmA.add(title);

vfmA.add(new SeparatorField());

vfmA.add(data);

vfmA.add(new SeparatorField());

vfmA.add(desc);

vfmA.add(new SeparatorField());

HorizontalFieldManager hfmA = new HorizontalFieldManager();

cancelButton = new ButtonField("Cancel");

cancelButton.setChangeListener(this);

hfmA.add(cancelButton);

linkButton = new ButtonField("Full Story");

linkButton.setChangeListener(this);

hfmA.add(linkButton);

add(vfmA);

add(hfmA);

//vfmA.setVerticalScroll(0);

vfmA.getField(0).setFocus();

}

 

I've tried with setFocus(), setVerticalScroll() but no success...

 

 

................................................................................................
Tech On!
PTNews
more at On On On!
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: focus on top of screen

[ Edited ]

This can be either easy or suprisingly difficult, depending on what exactly you want to achieve and on how big are your fields, most probably aDescTratada. If this string is several screens long, you'll need some careful screen position control.


However, in the simpler case one NullField is all you need. Here is a basic but good knowledge base article explaining the approach:

My scrollable manager is not scrolling

In your case you might want to add a NullField before the title.

 

However, there is a trick to the title allowing you to have it always shown on the screen - something that is quite logical in some cases and totally wrong in others. Likewise, your hfmA might or might not belong to the status area.

Take a look here for more detail:

MainScreen explained

 

Ask more if you are stuck.

Good luck!

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Trusted Contributor
jppedroso
Posts: 119
Registered: ‎04-29-2010
My Device: Curve 8520
My Carrier: TMN

Re: focus on top of screen

It worked! 

I've tried the "NullField" solution and it solved my problem.

Thks

................................................................................................
Tech On!
PTNews
more at On On On!
Please use plain text.