B. Money
B. Money

Reputation: 931

Why Isn't My Textview Setting Text In Widget

I'm a noob to android and i'm trying to loop text in two textviews in a widget with text from an ArrayList. For some reason, the widget is only showing the first text values from the ArrayList and not looping the subsequent values. I'm sure my Arraylist has multiple values so that's no the problem. Any help is greatly appreciated.

My Code;

void updateStory() {

    tickerheadline = RssReader.rssheadline.get(storyCounter);
    tickerstory = RssReader.rssstory.get(storyCounter);
    remoteViews.setTextViewText(R.id.headline, tickerheadline );
    remoteViews.setTextViewText(R.id.story, tickerstory );
    if (storyCounter==RssReader.rssheadline.size()-1){
        storyCounter = 0;
    }else{
        storyCounter++;
    }
    appWidgetManager.updateAppWidget(R.layout.widget1, remoteViews);

    mHandler.postDelayed(new Runnable() { 
         public void run() { 
           updateStory(); 
         } } ,5000);  }

}

Upvotes: 0

Views: 71

Answers (1)

paul
paul

Reputation: 805

You need to update the widget through the AppWidgetManager after each change.

AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);

Upvotes: 2

Related Questions