2012-12-20 5 views
5

내 응용 프로그램에서 나는 자동 스크롤 텍스트 뷰를 구현해야하는데, 나는 this 링크를 참조했다. 이제android에서 스크롤 Textview

나는 내 요구에 따라 tetxview.But 스크롤 한 내가 ... (I 구문 분석하고 난 일부 문자열이) 문자열 배열을 가지고 배열 지금 내가 원하는

string[] array=new string{"fgsdfd","gdfghdjhsd","gdfjhsgfhds"}; 

수 있습니다 고려한다는 것입니다 이 배열은 해당 텍스트 뷰에 표시됩니다 (자동으로 스크롤 됨).

나는 다음과 같이합니다 : 나는 tetxview..Please에 문자열의 배열을 설정하는 방법

<TextView 
    android:text="Really Long Scrolling Text Goes Here.... ..... ............ .... ...." 
    android:singleLine="true" 
    android:ellipsize="marquee" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:scrollHorizontally="true" 
    android:id="@+id/TextView03" 
    android:padding="5dip" 
    android:layout_width="wrap_content" 
    android:textColor="#000000" 
    android:layout_height="wrap_content" /> 

날 도와 : 이것은 (스크롤) 내 텍스트 뷰입니다

fgsdfd gdfghdjhsd gdfjhsgfhds------------------>this will scroll automatically 

.

답변

1

StringBuilder를 사용해보십시오. 이것에 대한

String[] array = { "fgsdfd", "gdfghdjhsd", "gdfjhsgfhds" }; 
StringBuilder sb = new StringBuilder(); 

for (int i = 0; i < array.length; i++) { 
    sb.append(array[i]); 
} 
txtView.setText(sb.toString()); 
+0

답변 해 주셔서 감사합니다. – Subburaj

3

문자열을 모두 StringBuilder으로 한 문자열에 병합하고 TextView에 적용 할 수 있습니다.

나는 텍스트 뷰를 포장하여 스크롤 내 자신의 텍스트 뷰를 구현했습니다 (그리고 아마도 다른 뷰)

private Runnable scrollRight = new Runnable() 
{ 

    @Override 
    public void run() 
    { 
        // can control scrolling speed in on tick 
     topScroll.smoothScrollBy(1, 0); 
    } 
}; 

및 새로운 스레드에서 나는 호출 :

while (!interruptScroll){ 
    try{ 
     Thread.sleep(50); // control ticking speed 
    } 
    catch (InterruptedException e){ 
     e.printStackTrace(); 
    } 
    topScroll.post(scrollRight); 
} 

및 수동으로있는 ScrollView를 스크롤하여 스크롤을 중단합니다 (사용자가 중단하지 않은 상태에서 자동 스크롤).

+0

감사합니다 .. – Subburaj

+0

그리고 BTW는 - 자동 스크롤이 타이머 \있는 ScrollView, smoothScrollBy 스레드를 사용하여 구현합니다. – dilix

+0

k ... 고맙습니다 dilix ... 1 더 많은 부탁을 할 수 있습니다 위의 코드에서 스크롤이 매우 느리게 일어나고 있습니다 .. 나는 조금 빨리 스크롤하고 싶습니다 .. 어떻게 위 코드에서 수행 할 수 있습니다 .. – Subburaj

0

시도, 답변

<TextView 
android:text="Really Long Scrolling Text Goes Here.... ..... ............ .... ...." 
android:singleLine="true" 
android:ellipsize="marquee" 
android:marqueeRepeatLimit="marquee_forever" 
android:scrollbars="horizontal" 
android:id="@+id/TextView03" 
android:padding="5dip" 
android:layout_width="wrap_content" 
android:textColor="#000000" 
android:layout_height="wrap_content" /> 
관련 문제