+ id);// Create a new Remote Views object using the appropriate // item layoutRemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.my_media_widget_item_layout);// Assign the values extracted from the Cursor to the Remote Views. rv.setImageViewUri(R.id.widget_media_thumbnail, uri);// Assign the item-specific fill-in Intent that will populate // the Pending Intent template specified in the App Widget // Provider. In this instance the template Intent specifies // an ACTION_VIEW action.Intent fillInIntent = new Intent(); fillInIntent.setData(uri);rv.setOnClickFillInIntent(R.id.widget_media_thumbnail,fillInIntent);return rv;}public int getViewTypeCount() {// The number of different view definitions to use.// For Content Providers, this will almost always be 1. return 1;}public boolean hasStableIds() {// Content Provider IDs should be unique and permanent. return true;}public void onDestroy() {// Close the result Cursor. c.close();}public RemoteViews getLoadingView() {// Use the default loading view. return null; This more flexible alternative for exposing Content Provider data on the home screen is a replace¬ment for Live Folders, which have now been deprecated.Refreshing Your Collection View WidgetsThe App Widget Manager includes the notifyAppWidgetViewDataChanged method, which allows you to specify a Widget ID (or array of IDs) to update, along with the resource identifier for the col¬lection View within that Widget whose underlying data source has changed:appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds,
R.id.widget_stack_view);
This will cause the onDataSetChanged handler within the associated Remote
đang được dịch, vui lòng đợi..