我们知道要在AppWidget里添加 View都是通过RemoteView来做到了,然而RemoteView本身功能很弱,支持的操作很少,而且支持RemoteView的Widget很少:
在Dev Guide中有下面这段:
引用
A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:
* FrameLayout
* LinearLayout
* RelativeLayout
And the following widget classes:
* AnalogClock
* Button
* Chronometer
* ImageButton
* ImageView
* ProgressBar
* TextView
Descendants of these classes are not supported.
所以从这里可以知道,为什么在AppWidget里添加EditText会显示LoadError了,因为本身它就不支持这些复杂的 Widget.
但我们又会有疑问了,为什么Google Search会有EditText呢?其实这些都是假象,并不是AppWidget支持EditText.
具体怎么回事,我猜有两种情况:
1.一种确实是EditText但确不是AppWidget 支持的,而是集成到Home里面去了。
具体可以参考这里:http://www.eoeandroid.com/archiver/tid-1729.html
2.最新的SDK 1.6中,显示在桌面的EditText只是一个ImageView,而这个ImageView的背景就是EditText的截图了。我们点中这个“EditText”后,会调起一个Activity,
而这个Activity就是复杂输入的EditText,并且会全屏显示。所以我们就误以会那是一个单纯的EditText.
AppWidget的RemoteView功能有限,仅支持特定布局和简单Widget,如FrameLayout、LinearLayout、RelativeLayout以及AnalogClock、Button等。由于不支持EditText,导致在尝试添加时会出现LoadError。Google Search看似包含EditText,实际上可能是集成到Home应用中或使用1.6 SDK中的技巧,通过ImageView显示EditText截图并在点击后启动全屏Activity进行复杂输入,从而造成误解。

被折叠的 条评论
为什么被折叠?



