我使用下面的代码来设置轨迹球的灵敏度
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
当我在usingTrackball.getSensitivityX()
和Trackball.getSensitivityY()
in 中检查轨迹球的灵敏度时navigationMovement
,它返回“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
}
}
它还通过 usingTrackball.getSensitivityX()
和Trackball.getSensitivityY()
in返回“2147483647” navigationMovement
。
最后,基于一些网络搜索,我将条件移动到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 ......等每次移动都绕过字段!
如何正确设置屏幕轨迹球的灵敏度?