문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top