0

I want to add items from a service in a ListView which is displayed in a widget. But how can I get my ListView in the Service? My widget layout looks like this:

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</ListView>

And with this Code I can get the RemoteViews from my widget:

AppWidgetManager mgr = AppWidgetManager.getInstance(ctx);
RemoteViews rv = new RemoteViews(ctx.getPackageName(), R.layout.widget_layout);

But now how can I get my ListView from the RemoteViews?

Cilenco
  • 6,951
  • 17
  • 72
  • 152
  • [Here](https://github.com/laaptu/appwidget-listview/tree/appwidget-listview1) is an example which seems to do exactly what you need. – Toon Borgers Dec 19 '13 at 06:55

1 Answers1

1

You will need a RemoteViewFactory class which is the adaptor for your ListView;

rv.setRemoteAdapter(appWidgetId, R.id.listView1,
                            serviceIntent);

Go through this link. I guess this is exactly what you want.

AabidMulani
  • 2,325
  • 1
  • 28
  • 47
  • Thanks for that. I tried with that but the widget does not update. Here I have posted my problem. Would be nice if you acn have a look on it: http://stackoverflow.com/questions/20704139/listview-in-widget-does-not-update – Cilenco Dec 20 '13 at 13:21
  • Can you tell me how I can set an OnItemClickListener for this ListView? – Cilenco Dec 23 '13 at 12:48