黑莓无效速度问题
我有带有音量滑块的自定义字段(只是颜色线), 我想更新触控板移动上的滑块,还有其他方法吗 然后调用无效?因为这对我来说真的很慢, 尝试也仅使区域无效,但结果相同。那么有吗 某种方式如何重新绘制部分字段而不失效?
protected boolean navigationMovement(int dx, int dy, int status, int time) {
if (dx >0) {
if (value < maxValue) {
value++;
invalidate(xPosSlider + value*sliderStep, getHeight()/2 - SLIDER_HEIGHT/2, sliderStep, SLIDER_HEIGHT);
return true;
}
} else if (dx < 0) {
if (value > 0) {
value--;
invalidate();
return true;
}
}
return super.navigationMovement(dx, dy, status, time);
}
I have custom field with volume slider (just color line),
I want to update slider on trackpad movement, is there some other way
then invoking invalidate? Because this is realy slow for me,
a tried also invalidating only region but whit same result. So is there
some way how to repaint part of field without invalidate?
protected boolean navigationMovement(int dx, int dy, int status, int time) {
if (dx >0) {
if (value < maxValue) {
value++;
invalidate(xPosSlider + value*sliderStep, getHeight()/2 - SLIDER_HEIGHT/2, sliderStep, SLIDER_HEIGHT);
return true;
}
} else if (dx < 0) {
if (value > 0) {
value--;
invalidate();
return true;
}
}
return super.navigationMovement(dx, dy, status, time);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先要查看的是您自己的代码。您是否在偶数线程上执行了一些耗时的操作,导致绘制操作无法及时进行?这就是可能的问题。
否则,您可以尝试直接调用paint方法,如下所示。但最好的解决方案是确保您的事件线程不会忙于执行应在单独线程上完成的工作。
The first place to look is at your own code. Are you doing something time-consuming on the even thread that is preventing the paint operations from occurring in a timely manner? That's the likely problem.
Otherwise, you can try calling the paint method directly as shown here. But the best solution is to ensure that your event thread is not tied up doing work that should be done on a separate thread.