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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
Rajat_10Sep
Posts: 685
Registered: ‎12-02-2008

Re: ListField navigationClick problem

 

Hi,

 

I think you can use getPreferredHeight() and getPreferredWidth() methods of TextField() to resize you TextField.

 

I have used these methods for my ButtonField.

 

Here is the code.I think this should work for TextField also

add(new ButtonField("Set Reminder",ButtonField.FIELD_HCENTER | ButtonField.FIELD_VCENTER){ public int getPreferredWidth(){ return 130; } public int getPreferreHeight(){ return 30; } });

Instead of hardcoding your values you can write your logic.

 

Please let me know did it solved your problem or not.

 

Regards,

Rajat Gupta.

 

 

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.
Developer
Rajat_10Sep
Posts: 685
Registered: ‎12-02-2008

Re: ListField navigationClick problem

[ Edited ]

Please igone this post this was  by mistake

 

Hi,

 

I think you can use getPreferredWidth() and getPreferredHeight() methods of TextField to change size of your Field.

 

I have done this for my ButtonField hope it can help you out also.

 

Code for this is below.

 

      add(new ButtonField("Set Reminder",ButtonField.FIELD_HCENTER | ButtonField.FIELD_VCENTER){

                 public int getPreferredWidth(){
                    return 130;
                 }
                
                 public int getPreferreHeight(){
                    return 30;
                 }  
     });

 

Instead of returning hard coded values return values accordingly.

 

Please let me know this solved your problem or not.

 

Regards,

Rajat Gupta

Message Edited by Rajat_10Sep on 03-09-2009 07:05 AM
Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.
New Developer
danywv
Posts: 7
Registered: ‎03-09-2009

Re: ListField navigationClick problem

[ Edited ]

Hi again, thenks to all of you for the replyes. I finally fixed it :smileyhappy:. Following some hints here and after doing some reading on Layout managers I learned that scrolling is handled by the manager so I did the folowing: I set the screen manager to NO_VERTICAL_SCROLL and add the ListField in a scrollable Vertical manager. After that I added a focusable TextField to the screen and everything works like a charm. Here is the result in short, maybe someone else will bump into this problem:

 

super(MainScreen.FOCUSABLE | MainScreen.NO_VERTICAL_SCROLL);
.......
VerticalFieldManager l_manager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
add(l_manager);
l_manager.add(_itemList);
add(new TextField(TextField.FOCUSABLE | TextField.READONLY));

 

 

Edited to change NullField with TextField....aparently NullField didn't work after restarting the simulator...

 

Message Edited by danywv on 03-09-2009 10:00 AM
Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009

Re: ListField navigationClick problem

[ Edited ]

 

thanks danyw it works,  it was just enough for me to use :

super(MainScreen.FOCUSABLE | MainScreen.NO_VERTICAL_SCROLL);

 

and

add(new TextField(TextField.FOCUSABLE | TextField.READONLY));

but in order to prevent a problem when last row is selected and user press the down arrow key, i also used:

 

    protected boolean navigationMovement( int dx, int dy, int status, int time ){

invalidate();
if (listSettings.getSelectedIndex() == LASTINDEX && dy > 0)
return true;
...
Please use plain text.
Developer
ronenfe
Posts: 77
Registered: ‎06-03-2009

Re: ListField navigationClick problem

[ Edited ]

well, TextField constructor is not available in os 4.2.1.

Any alternative?

 

edit:

 

ok, BasicEditField works as well. but it get selected by scrolling to it in non touch devices.

 

I guess i will put an if condition to see if it's a touch device.

Please use plain text.
New Contributor
kpagariya
Posts: 2
Registered: ‎03-19-2010
My Carrier: student

Re: ListField navigationClick problem

 

 

Use this code :

 

public boolean navigationClick(int status, int time) {

       Field focus = UiApplication.getUiApplication().getActiveScreen() .getLeafFieldWithFocus();
            
            if (focus instanceof ListField) {
                int selected = menu.getSelectedIndex();
                switch (selected) {

 

                         case 0 :

 

                          case 1:

                }

       }

}

 

Kunal Pagariya

 

 

 

 

 

Please use plain text.