Horizontal Scrolling TextField

Hi, I scrolled the text at this LabelField Marquee link . But I have one problem, the text scrolls well, but it was written on top of the source text that was added. Can anyone understand how to deal with this problem? I also tried updating the view invalidate(), but to no avail. I added a screenshot of the problem I am facing.

Any help would be noticeable.

Thank.

enter image description here

+2
source share
2 answers

I would suggest you change the drawing method as follows:

 public void paint(Graphics graphics) {
    currentText = this.getText();
    if (currentChar < currentText.length()) {
        currentText = currentText.substring(currentChar);

    }
    graphics.drawText(currentText, 0, 0, DrawStyle.ELLIPSIS, 200);
}

Therefore, do not call super.paint()in paint.

+2
source

( ) , . .

import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.DrawStyle;
import java.util.Timer;
import java.util.TimerTask;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class MyScreen extends MainScreen {

    public MyScreen() {

        super();

        MarqueeLabel testLabel2 = new MarqueeLabel("This is a long long " +
                "long long long long long long long long long long long " +
                "long long marquee", Field.FOCUSABLE);
        add(testLabel2);

    }

    class MarqueeLabel extends LabelField {

        // Here MarqueeLabel code from your SO linked example

    }

}
+1

Source: https://habr.com/ru/post/1534026/


All Articles