我在一个ViewFlipper中嵌套了两个ListView小部件:
<ViewFlipper android:id="@+id/flipper" android:layout_height="fill_parent" android:layout_width="fill_parent">
<ListView android:id="@+id/bikeListView" android:layout_height="wrap_content" android:layout_width="fill_parent" />
<ListView android:id="@+id/bikeComponentsListView" android:layout_height="wrap_content" android:layout_width="fill_parent" />
</ViewFlipper> 我在两个ListView小部件的自定义ListAdapter类的getView()方法中放置了一个日志,我发现当我在ViewFlipper getView中移动到下一个或上一个视图时,即使ListView不可见,它也会被调用。例如,当我从第一个ListView移动到第二个ListView时,将调用第一个的getView(),尽管显示了第二个ListView。
这是预期的行为吗?我的意图是使用ViewFlipper和onFling在ViewFlipper中来回移动,并以编程方式在ViewFlipper中添加许多ListView。
感谢您阅读我的问题。
发布于 2011-01-04 10:54:41
我遇到了同样的问题,发现这是因为你的layout_height设置为wrap_content....see这篇文章以获取更多信息:
http://www.anddev.org/view-layout-resource-problems-f27/multiple-calls-of-getview-in-arrayadapter-t16595.html
https://stackoverflow.com/questions/3123066
复制相似问题