有个问题,我建了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.csdn.net/u/20100813/19/af4d1844-1a55-4915-848f-5191593172ca.html