10-05-2012 07:16 AM
I have 5 bitmapfields in horizontalfield manager. When screen is displayed focus is set to first bitmapfield by default. i want to set it to 2nd bitmapfield. how to do it?
HorizontalfieldManager h = new HorizontalFieldManager()
{
protected void sublayout(int maxWidth, int maxHeight) {
Field f = this.getField(2);
f.setFocus();
super.sublayout(maxWidth, maxHeight);
}
I tried above code. Still focus is set on first field
10-05-2012 07:55 AM
Hi Jovinz,
The better approach to set focus after screen loads into stack is,
protected void onUiEngineAttached(boolean attached) {
if(attached){
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Field f =//get your required field
if(f != null)f.setFocus();
}
});
}
}
Thanks.