/** * Creates a layout depending on the current sdk version * * * @param context Application context * @param appWidgetId Id of the widget * @param options Widgets options * @return RemoteViews for the layout */ internal static RemoteViews CreateLayout(Context context, int appWidgetId) { // Only in api >= 11 (Honeycomb) can we support the large layout because we depend on // the remote view service. return(((int)Build.VERSION.SdkInt >= 11) ? RemoteViewsFactory.CreateLargeLayout(context, appWidgetId) : RemoteViewsFactory.CreateSmallLayout(context, appWidgetId)); }
/** * Creates a layout depending on the app widgets options * * @param context Application context * @param appWidgetId Id of the widget * @param options Widgets options * @return RemoteViews for the layout */ internal static RemoteViews CreateLayout(Context context, int appWidgetId, Bundle options) { bool isLargeLayout = options.GetInt(AppWidgetManager.OptionAppwidgetMinHeight) >= 100; return(isLargeLayout ? RemoteViewsFactory.CreateLargeLayout(context, appWidgetId) : RemoteViewsFactory.CreateSmallLayout(context, appWidgetId)); }
public void OnAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) { RemoteViews layout = RemoteViewsFactory.CreateLayout(context, appWidgetId, newOptions); appWidgetManager.UpdateAppWidget(appWidgetId, layout); }
public void OnUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { // Update each of the widgets with the remote adapter foreach (int id in appWidgetIds) { RemoteViews layout = null; // API 16 and above supports reconfigurable layouts if ((int)Build.VERSION.SdkInt >= 16) { Bundle options = appWidgetManager.GetAppWidgetOptions(id); layout = RemoteViewsFactory.CreateLayout(context, id, options); } else { layout = RemoteViewsFactory.CreateLayout(context, id); } appWidgetManager.UpdateAppWidget(id, layout); } base.OnUpdate(context, appWidgetManager, appWidgetIds); }