03-09-2009 06:57 AM
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.
03-09-2009 07:04 AM - edited 03-09-2009 07:05 AM
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
03-09-2009 08:55 AM - edited 03-09-2009 10:00 AM
Hi again, thenks to all of you for the replyes. I finally fixed it
. 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...
03-19-2010 04:46 PM - edited 03-19-2010 04:52 PM
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;
...
03-21-2010 04:42 PM - edited 03-21-2010 06:06 PM
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.
04-01-2010 05:57 AM
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