Android 3.0:Stackview 示例非小部件

发布于 2024-10-24 02:27:38 字数 141 浏览 6 评论 0原文

我正在尝试在 Activity 中使用 StackView,并使用 BaseAdapter 作为 StackView 中的视图。即使适配器中的 getView 被调用,也没有显示任何内容。有人有幸让 StackView 在 Activity 中工作吗?知道一个例子吗?

I'm trying to use a StackView in an Activity using a BaseAdapter for the views in the StackView. Nothing is showing up, even though my getView in the adapter is being called. Anyone have any luck getting StackView to work in an Activity? Know of an example?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小嗷兮 2024-10-31 02:27:39

这是一个显示 Activity 中 stackview 用法的教程。它是土耳其语的,但源代码足以理解: http://www.devandroidtr.org/?p =137

更新

英文示例教程:
http://www.gdgankara.org/2012/03/ 25/stackview-non-widget-sample/

Here is a tutorial that show stackview usage in Activity. It is in Turkish but source code is enough to understand: http://www.devandroidtr.org/?p=137

Updated

The sample tutorial in English:
http://www.gdgankara.org/2012/03/25/stackview-non-widget-sample/

瀞厅☆埖开 2024-10-31 02:27:39

我成功了。如何声明视图的大小确实很挑剔。如果您正在下载图像并填充视图,则无法执行wrap_content,它似乎需要事先测量布局,因此,如果您的视图直到稍后才加载,您将不会绘制任何内容。在加载到 StackView 中的视图上指定设置的高度/宽度就可以了。

I got it working. It's really picky about how you declare the size of your views. You can't do wrap_content if you are downloading images and populating your views, it seems to need to measure the layout beforehand, so if your views aren't loaded until later you will get nothing drawn. Specify a set height/width on your views that load into the StackView and you're good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文