RemoteViews - void 方法 setRemoteAdapter
我正在尝试实现一个小部件,其布局具有 GridView。我的小部件类中的 onUpdate 方法是:
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
int widgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widget);
/**views.setRemoteAdapter(..)**/
Intent intent = new Intent(context, MainAppDelegate.class);
appWidgetManager.updateAppWidget(widgetId, views);
}
}
问题是,当我调用 views.setRemoteAdapter(..) java 不知道它是什么方法。为什么会发生这种情况?需要升级sdk吗?此外,它无法识别 setBundle() 方法
I'm trying to implement a widget, with a layout that has a GridView. My onUpdate method inside the widget class is:
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
final int N = appWidgetIds.length;
for (int i=0; i<N; i++) {
int widgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widget);
/**views.setRemoteAdapter(..)**/
Intent intent = new Intent(context, MainAppDelegate.class);
appWidgetManager.updateAppWidget(widgetId, views);
}
}
The thing is that when I call views.setRemoteAdapter(..) java doesn't know what method it is. Why is that happening? Do I need to upgrade the sdk? Also, it doesn't recognise setBundle() method
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
setRemoteAdapter()
仅在 API Level 11 上可用。您需要将构建目标设置为 API Level 11 或更高版本才能使用此方法进行编译,并且需要注意确保此代码随后仅在 API 级别 11 或更高版本的设备上运行。setRemoteAdapter()
is only available on API Level 11. You need to have your build target set to API Level 11 or higher to compile using this method, and you need to take care to ensure that this code then only runs on API Level 11 or higher devices.