Get ListView from widget layout

995 views Asked by At

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?

1

There are 1 answers

2
AabidMulani On BEST ANSWER

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.