开发者

how to set a listview into an appwidget?

I want to create an appwidget in which I want to show some data from a resource in a list view. I am new in android so I am not getting any 开发者_运维问答idea. Please help

Thanks in Advance


Basically you can't use a ListView with an app widget on phones. It's not a supported View (for a list of supported ones, look here).

The true story is a bit more complicated, there are two exceptions to this rule:

First, you can use it on Honeycomb (Android 3.0+), but thats only tablets at the moment. I never have worked with this and from a short search, the doc seems a bit lacking here, found hardly any evidence of this (it's noted inside the Android 3.0 Platform API overview under "App widgets" - there are also links to a few samples).

Second, some alternative launchers do support the ListView. I don't know exactly which ones, heres a quote from the "Pure messenger widget" description in the Android market:

Scrollable widget with most alternative launchers like ADW, LiveHome, Go Launcher Ex or LauncherPro

That means most custom launchers that you can install from the Market. It does not include proprietary launchers which support ListViews in an undocumented manner - e.g. HTC Sense.

I'm not sure if you can do some compatibility testing for alt-launchers. You may use res specifiers to split Honeycomb devices from the rest, but even then you are still incompatible with many vanilla devices or default launchers from the manufacturers.

To sum it up: It's a very bad situation for ListViews at the moment.

(Weak alternative: Of course you can build a "fake listview" that looks like a list, but is a static layout out of the supported Views. But that won't scroll.)


Note: I'm aware that this is more of an "can you" answer than how to actually do it - which is the actual question. I think it's still useful since it is a weird situation. You see often that ListViews work, but you can't get it to run which may confuse people new to the platform. I hope this makes clear, when you are able to use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜