2012-08-15 6 views
2

안녕하세요 저는이 링크를 통해 스크롤 텍스트를 가로로 구현했습니다 LabelField Marquee. 하지만 한 가지 문제가 있습니다. 텍스트가 잘 스크롤되었지만 추가 된 원래 텍스트 위에 덮어 씌여졌습니다.이 문제를 해결하는 방법을 알고있는 사람이 있습니까? 나는 또한 invalidate()로보기를 새로 고치려고했으나 사용하지 않았습니다. 내가 직면하고있는 문제의 스크린 샷을 추가했습니다.TextField 가로 스크롤

도움이 될 것입니다.

감사합니다. 나는 (더 간단한 방법으로) 다시 한

enter image description here

답변

2

난 당신이 다음에 페인트 방법을 변경 제안 :

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

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

그래서 당신 paintsuper.paint()를 호출하지 않습니다.

+0

thankx @ Eugen.Thankx 많은 남자 :) .. 내 실수로 super.paint()를 내 페인트 방법으로 불렀습니다. – AkashG

+0

잘 작동하지만 중간에서 왼쪽으로 테스트를 표시합니다. 텍스트는 오른쪽에서 왼쪽으로 텍스트가 작거나 큽니다. 내가이 코드로 어떻게 할 수 있겠 니? – Hasmukh

+0

소스 코드를 살펴보십시오 - 다른 글꼴을 레이블 필드에 설정하고 0 위치에서 시작하여 매 틱마다 4 개의 기호를 이동하는 대신 text.length()로 시작하고 4 기호를 왼쪽으로 이동하십시오 (+ 동작을 -로 변경) . 계속 질문이있는 경우 - 새 주제를 작성하십시오. –

1

당신이 연결 대답. 그것은 잘 작동합니다.

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 

    } 

} 
+0

같은 문제가 여전히 있습니다. ( – AkashG

+0

오늘 아침에 다시 시도했는데 결과는 똑같습니다. 계속 움직이고 있지만 텍스트를 랩핑하는 중 ... 제발 저를 버리십시오. – AkashG

+0

8520 시뮬레이터에서 JRE 5.0.0을 사용하고 있습니다. Eclipse 1.3.0 용 자바 플러그인 – rosco