问题的解决:SpinBoxFieldManager中,可是光标只能在3个spin box来回移动,不能移动到下面的其他field了...

解决Spinbox焦点问题

有个问题,我建了3个TextSpinBoxField放入了SpinBoxFieldManager中,可是光标只能在3个spin box来回移动,不能移动到下面的其他field了,我是要重写什么方法还是怎么处理

解决:

核心是扩展SpinBoxFieldManager对象,在其navigationMovement()方法中只处理左右移动(move dx>0 or dx <0)。

不处理dy的,交由上级Manager处理 return super.navigationMovement(dx,dy,status,time);

public class HelloWorldDemo extends UiApplication { /** * Entry point for application * @param args Command line arguments (not used) */ public static void main(String[] args) { // Create a new instance of the application and make the currently // running thread the application's event dispatch thread. HelloWorldDemo theApp = new HelloWorldDemo(); theApp.enterEventDispatcher(); } /** * Creates a new HelloWorldDemo object */ public HelloWorldDemo() { // Push a screen onto the UI stack for rendering. pushScreen(new HelloWorldScreen()); } } /** * A class extending the MainScreen class, which provides default standard * behavior for BlackBerry GUI applications. */ final class HelloWorldScreen extends MainScreen { RichTextField text = new RichTextField("Hello World!", Field.FOCUSABLE); TextSpinBoxField spinBoxDays; TextSpinBoxField spinBoxMonths; SpinBoxFieldManager spinBoxMgr; HelloWorldScreen() { // Set the displayed title of the screen //setTitle("Hello World Demo"); HorizontalFieldManager mgr = new HorizontalFieldManager(); Bitmap image = Bitmap.getBitmapResource("icon0001.PNG"); BitmapField icon = new BitmapField(image, BitmapField.NON_FOCUSABLE); mgr.add(icon); mgr.add(new LabelField("Hello World Demo")); setTitle(mgr); add(text); spinBoxMgr = new SpinBoxFieldManager() { protected boolean navigationMovement( int dx, int dy, int status, int time ) { if(dx>0) { int fieldCount = getFieldCount(); int focusIndex = getFieldWithFocusIndex(); if (focusIndex >= fieldCount-1) { text.setFocus(); return true; } } return super.navigationMovement(dx,dy,status,time); } }; final String[] DAYS = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"}; final String[] MONTHS = {"January","February","March","April","May","June","July","August","September","October","November","December"}; spinBoxDays = new TextSpinBoxField(DAYS); spinBoxMonths = new TextSpinBoxField(MONTHS); spinBoxMgr.add(spinBoxDays); spinBoxMgr.add(spinBoxMonths); add(spinBoxMgr); }

原文:

http://topic.youkuaiyun.com/u/20100813/19/af4d1844-1a55-4915-848f-5191593172ca.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值