【发布时间】:2017-04-30 19:04:49
【问题描述】:
使用滑翔库。 这就像正常的图片。 我尝试了 glide 库,但它不起作用。 使用滑动库。 这就像正常的图片。 我尝试了滑翔库,但它不起作用。
public class NewAppWidget extends AppWidgetProvider {
private static AppWidgetTarget appWidgetTarget;
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
CharSequence widgetText = NewAppWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
// Construct the RemoteViews object
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);
views.setTextViewText(R.id.appwidget_text, widgetText);
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);
appWidgetTarget = new AppWidgetTarget( context, rv, R.id.imageView, appWidgetId );
Glide
.with( context.getApplicationContext() ) // safer!
.load("https://i.giphy.com/l4FGq1K2WUMWYSisw.gif")
.asBitmap()
.into(appWidgetTarget);
pushWidgetUpdate(context, rv);
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
public static void pushWidgetUpdate(Context context, RemoteViews rv) {
ComponentName myWidget = new ComponentName(context, NewAppWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
manager.updateAppWidget(myWidget, rv);
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
// There may be multiple widgets active, so update all of them
for (int appWidgetId : appWidgetIds) {
updateAppWidget(context, appWidgetManager, appWidgetId);
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.new_app_widget);
appWidgetTarget = new AppWidgetTarget( context, rv, R.id.imageView, appWidgetIds );
Glide
.with( context.getApplicationContext() ) // safer!
.load("https://i.giphy.com/l4FGq1K2WUMWYSisw.gif")
.asBitmap()
.into(appWidgetTarget);
pushWidgetUpdate(context, rv);
}
}
我的英语不好,我已经道歉了,我可以告诉你我可以告诉你。 谢谢
【问题讨论】: