我使用以下代碼來設置軌跡球在Blackberry中,設置軌跡球靈敏度不起作用?
public class Main extends UiApplication {
public static void main(String[] args) {
Main theApp = new Main();
theApp.enterEventDispatcher();
}
public Main() {
if (Trackball.isSupported()) {
Trackball.setFilter(Trackball.FILTER_ACCELERATION);
Trackball.setSensitivityX(20);
Trackball.setSensitivityY(20);
}
pushScreen(new LoginScreen());
}
}
這裏的靈敏度真實使用的屏幕:
public class LoginScreen extends MainScreen {
public LoginScreen() {
super(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_VERTICAL_SCROLLBAR);
add(...) // SOME COMPONENTS ARE ADDED HERE
}
}
當我檢查軌跡球在LoginScreen
的靈敏度navigationMovement
使用Trackball.getSensitivityX()
和Trackball.getSensitivityY()
,它返回「2147483647」,同時如果我立即在Main
之後檢查它,它將返回「20」!
所以我感動設置塊的LoginScreen
內部本身如下:
public class LoginScreen extends MainScreen {
public LoginScreen() {
super(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_VERTICAL_SCROLLBAR);
if (Trackball.isSupported()) {
Trackball.setFilter(Trackball.FILTER_ACCELERATION);
Trackball.setSensitivityX(20);
Trackball.setSensitivityY(20);
}
add(...) // SOME COMPONENTS ARE ADDED HERE
}
}
它也返回 「2147483647」 通過在navigationMovement
使用Trackball.getSensitivityX()
和Trackball.getSensitivityY()
。
最後,基於一些web搜索,我移動navigationMovement
內的條件,如下所示:
protected boolean navigationMovement(int dx, int dy, int status, int time) {
if (Trackball.isSupported()) {
Trackball.setFilter(Trackball.FILTER_ACCELERATION);
Trackball.setSensitivityX(20);
Trackball.setSensitivityY(20);
}
return super.navigationMovement(dx, dy, status, time);
}
問題變得該導航運動從字段在索引0處跳轉到索引2到索引4 ...等每場比賽繞過場!
如何正確設置軌跡球對屏幕的靈敏度?
非常感謝,它的工作:) –