I am an android for noob, and I am trying to create a widget that uses a text selection area to display tweets in a ticker. When I set the text in xml, the step label displays correctly in the widgets. However, when I try to set the text programmatically, the selection does not scroll. The text is set, but it just does not scroll. This behavior is bewildering because I used this question as my guide. Any help is appreciated.
My layout
<TextView android:id="@+id/ticker" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:duplicateParentState="true" android:ellipsize="marquee" android:fadingEdge="horizontal" android:focusable="true" android:focusableInTouchMode="true" android:lines="1" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:text="Simple application that shows how to use marquee, with a long text for Twitter Feed" > //<--this text scrolls fine <requestFocus android:duplicateParentState="true" android:focusable="true" android:focusableInTouchMode="true" /> </TextView>
My code
public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { //String currentTime = df.format(new Date()); String spotgold = String.valueOf(MyActivity.widgetlivespotgold); String spotsilver = String.valueOf(MyActivity.widgetlivespotsilver); StringBuilder tickertweets=new StringBuilder(); for (int i = 0; i < MyActivity.twittername.size(); i++) { tickertweets.append(MyActivity.twittername.get(i) + ":" + " " + MyActivityActivity.twittertweet.get(i) + " "); } RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget1); updateViews.setTextViewText(R.id.goldspot, spotgold); updateViews.setTextViewText(R.id.silverspot, spotsilver); updateViews.setTextViewText(R.id.ticker, tickertweets.toString()); //Text is set, but doesn't scroll appWidgetManager.updateAppWidget(appWidgetId, updateViews); }
source share