In my application i have to implement an automatically scrolling textview, I referred this link .
Now I have a scrolling tetxview.But according to my requirement is that I have a string array(I have parsed and I have some string)..Consider the array may be
string[] array=new string{"fgsdfd","gdfghdjhsd","gdfjhsgfhds"};
Now i want this array to be displayed in that textview(which will scroll automatically).
I want like this:
fgsdfd gdfghdjhsd gdfjhsgfhds------------------>this will scroll automatically
This is my textview(scrolling):
<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" />
How can I set an array of string to a tetxview..Please help me.
You can merge all of your string in one string by StringBuilder
and apply it to the TextView
.
I've implemented my own TextView with scrolling by wrapping textview (and maybe some other views)
private Runnable scrollRight = new Runnable()
{
@Override
public void run()
{
// can control scrolling speed in on tick
topScroll.smoothScrollBy(1, 0);
}
};
and in new Thread I invoke:
while (!interruptScroll){
try{
Thread.sleep(50); // control ticking speed
}
catch (InterruptedException e){
e.printStackTrace();
}
topScroll.post(scrollRight);
}
and by manually scrolling the scrollView i interrupt the scrolling (such an automatic scrolling while not interrupted by user).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With