黑莓 - 如何动画自定义字段? [英] Blackberry - how to animate Custom Field?

查看:160
本文介绍了黑莓 - 如何动画自定义字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义字段级求绘制fillrectangle。

I have created a custom field class "Seek" to draw a fillrectangle.

class Seek extends Field {
    int fill;
    protected void layout(int width, int height) {
    	setExtent(320, 5);
    }
    protected void paint(Graphics graphics) {
    	graphics.setColor(Color.RED);
    	graphics.fillRect(0, 0, fill, 5);
    }
    protected void setValue(int value) {
    	fill = value;
    }
}

和我创造了另一个类测试寻求使用定时器设置填充值

And I have created another class Test seek to set the fill value using a timer

public class TestSeek extends UiApplication {
    public static void main(String[] args) {
    	TestSeek gbResults = new TestSeek();
    	gbResults.enterEventDispatcher();
    }
    private TestSeek() {
    	pushScreen(new ProgressScreen());
    }
}

class ProgressScreen extends MainScreen {
    Timer timer = new Timer();
    int i = 80;
    Seek SeekField = new Seek();

    public ProgressScreen() {
    	add(SeekField);
    	timer.schedule(new RemindTask(), 100, 10);
    }

    class RemindTask extends TimerTask {
    	public void run() {
    		if (i < 320) {
    			i += 1;
    			SeekField.setValue(i);
    		} else
    			timer.cancel();
    	}
    }
}

不过,我无法填补动画矩形。

But I am unable to animate filling the rectangle.

推荐答案

请尝试调用无效()在你的setValue方法。

Try calling invalidate() in your setValue method.

这篇关于黑莓 - 如何动画自定义字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆