appWidgetIds和最好的方式来定义多个大小(或调整大小)小部件 [英] appWidgetIds and best way to define multiple size (or resizable) widget

查看:384
本文介绍了appWidgetIds和最好的方式来定义多个大小(或调整大小)小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要定义多个尺寸部件我看到了一个常见的​​做法是定义多个接收器和提供其他问题,但是在的onUpdate 方法,我注意到,有一个名为数组 appWidgetIds 例如:

I want to define multiple size widgets I have sees in other questions that a common practice is to define multiple receivers and providers, however in the onUpdate method I have noticed that there is an array named appWidgetIds eg

public void onUpdate(Context c, AppWidgetManager appWidgetManager,
                         int[] appWidgetIds) {
        for (int i = 0; i < appWidgetIds.length; i++) {
.....
....
  }
}

所以我不知道这是什么阵的目的,如果可用于定义多个大小小部件不产生不同的提供者和接收者。

so I'm wondering what is the purpose of this array and if could be used for define multiple size widget without create different providers and receivers.

请注意,我的不同大小的部件采用相同的设计,不同的是在小部件的一些元素缺失,为此一种方式来避免定义多个提供商做几乎同样的事情是值得欢迎的。

Note that my different size widget use the same design with the difference that in smaller widgets some elements are missing, for this reason a way to avoid to define multiple providers that do almost the same things is welcome.

推荐答案

该阵列是他们把小部件的多个实例的情况下,这样他们就可以全部更新。大多数时候,你呼吁所有控件的ID相同的更新code,但是这允许您选择不同的操作,例如,如果你的应用程序上有多个账户,也可以有不同的部件。

The array is in case they put multiple instances of the widget, so they can all be updated. Most of the time you call the same update code on all widget id's, but this allows you to pick different actions such as if your app has multiple accounts on it, they can have different widgets.

大小与接收机指定为在较旧的API描述的,而较新的能够调整的。

Sizes are specified with the receivers as described in older apis, while newer ones are capable of resizing.

这篇关于appWidgetIds和最好的方式来定义多个大小(或调整大小)小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆