android - textView marquee -
i want put textview in homescreen, , need marquee effect
public class mainwidget extends appwidgetprovider { int a; remoteviews remoteviews; appwidgetmanager appwidgetmanager; componentname thiswidget; string[] s={"woddfdfdfdfdfdffffffffffffffffffffffffffffffff","dd","ddd","ffff"}; public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { timer timer = new timer(); timer.scheduleatfixedrate(new wlantimer(context, appwidgetmanager), 100, 50000); } private class wlantimer extends timertask { remoteviews remoteviews; appwidgetmanager appwidgetmanager; componentname thiswidget; public wlantimer(context context, appwidgetmanager appwidgetmanager) { this.appwidgetmanager = appwidgetmanager; remoteviews = new remoteviews(context.getpackagename(), r.layout.marketwidget_main); thiswidget = new componentname(context, mainwidget.class); } @override public void run() { a=(int) (math.random()*3); remoteviews.settextviewtext(r.id.textview_marketwidget_main_marketmessage,s[a]); appwidgetmanager.updateappwidget(thiswidget, remoteviews); } } }
if use s[0] instead s[a], not run, "woddfdf" shows up.
my textview xml is:
<textview android:id="@+id/textview_marketwidget_main_marketmessage" android:maxlines="1" android:focusable="true" android:ellipsize="marquee" android:inputtype="text" android:focusableintouchmode="true" android:marqueerepeatlimit="marquee_forever" android:textcolor="#ffffff" android:background="@android:color/transparent" android:layout_width="80dip" android:layout_height="20dip"></textview>
what got question is, want show scrolling marquee effect in textview? if right, following.
set android:ellipsize="marquee"
in textview
element in layout file (xml). then, in activity's oncreate()
method, add line textview.setselected(true);.
note: replace name textview name of textview.
revert query.
Comments
Post a Comment