to top
Android APIs
Added in API level 11
public static interface

RemoteViewsService.RemoteViewsFactory

android.widget.RemoteViewsService.RemoteViewsFactory

Class Overview

An interface for an adapter between a remote collection view (ListView, GridView, etc) and the underlying data for that view. The implementor is responsible for making a RemoteView for each item in the data set. This interface is a thin wrapper around Adapter.

Summary

Public Methods
abstract int getCount()
abstract long getItemId(int position)
abstract RemoteViews getLoadingView()
This allows for the use of a custom loading view which appears between the time that getViewAt(int) is called and returns.
abstract RemoteViews getViewAt(int position)
abstract int getViewTypeCount()
abstract boolean hasStableIds()
abstract void onCreate()
Called when your factory is first constructed.
abstract void onDataSetChanged()
Called when notifyDataSetChanged() is triggered on the remote adapter.
abstract void onDestroy()
Called when the last RemoteViewsAdapter that is associated with this factory is unbound.

Public Methods

public abstract int getCount ()

Added in API level 11
Returns
  • Count of items.

public abstract long getItemId (int position)

Added in API level 11
Parameters
position The position of the item within the data set whose row id we want.
Returns
  • The id of the item at the specified position.

public abstract RemoteViews getLoadingView ()

Added in API level 11

This allows for the use of a custom loading view which appears between the time that getViewAt(int) is called and returns. If null is returned, a default loading view will be used.

Returns
  • The RemoteViews representing the desired loading view.

public abstract RemoteViews getViewAt (int position)

Added in API level 11

See getView(int, android.view.View, android.view.ViewGroup). Note: expensive tasks can be safely performed synchronously within this method, and a loading view will be displayed in the interim. See getLoadingView().

Parameters
position The position of the item within the Factory's data set of the item whose view we want.
Returns
  • A RemoteViews object corresponding to the data at the specified position.

public abstract int getViewTypeCount ()

Added in API level 11
Returns
  • The number of types of Views that will be returned by this factory.

public abstract boolean hasStableIds ()

Added in API level 11
Returns
  • True if the same id always refers to the same object.

public abstract void onCreate ()

Added in API level 11

Called when your factory is first constructed. The same factory may be shared across multiple RemoteViewAdapters depending on the intent passed.

public abstract void onDataSetChanged ()

Added in API level 11

Called when notifyDataSetChanged() is triggered on the remote adapter. This allows a RemoteViewsFactory to respond to data changes by updating any internal references. Note: expensive tasks can be safely performed synchronously within this method. In the interim, the old data will be displayed within the widget.

public abstract void onDestroy ()

Added in API level 11

Called when the last RemoteViewsAdapter that is associated with this factory is unbound.