如何保持在Android的多页脚看法? [英] How to maintain multiple footer views in Android?

查看:132
本文介绍了如何保持在Android的多页脚看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView常添加/删除根据列表条件页脚。有时会出现进度来看,其他时间一个错误观点等问题的关键是,我经常需要换出页脚视图。但是页脚的观点必须设置或重置适配器,以便经常有奇怪的例外拆除现有的页脚视图将其与更换一个新的前加入。是的,我已经删除了页脚视图就在得到空指针异常,适配器类转换异常!

I have a ListView and often add/remove footers depending on list conditions. Sometimes a progress view is displayed, other times an error view etc. The point is that often I need to swap out the footer view. But footer views must be added before setting or resetting the adapter so there are often weird exceptions in removing the existing footer view to replace it with a new one. Yes, I have gotten null pointer exceptions, and adapter class cast exceptions just when removing the footer view!

因此​​,底线:它的困难和繁琐,毛利率维持数页脚的观点,但页脚房地产是非常有用的。

So the bottom line: Its difficult and verbose and gross to maintain several footer views, but the footer real estate is useful.

所以,我在想,我这也只是一个容器只是一个页脚,设置该页脚在开始时比添加/删除/隐藏子页脚意见,根据需要footerview。

So I was thinking about having just one footer which would just be a container, set this footer in the beginning and than add/remove/hide sub footer views to the footerview as needed.

这是处理这一问题的最佳方法是什么?请问footerview正确刷新,无需重新设置适配器,如果我在子页脚意见加入到退出footerview?

Is this the best way to handle this? Will the footerview properly refresh without resetting the adapter if I add in the sub footer views to the exiting footerview?

是否有不复位适配器页脚视图刷新选项?如何有其他人处理了这一点呢?

Is there a refresh option for the footer view without resetting adapter? How are other folks handling this out there?

推荐答案

记住的ListView创建和丢弃的物品,因为他们进入或走出画面。所以,如果你引用的项目独立,很可能你会得到空指针异常和许多其他错误。 您的实际问题是precisely的,而不是不同类型的页脚。

Remember that ListView creates and discards items as they come into or go out of screen. So if you reference the items independently it is very likely that you'll get null pointer exceptions and many other errors. Your actual problem is precisely that and not the different types of footers.

所以处理页脚之前确保该项目实际上是可见的(不是null,里面的画面全部或部分。)

So before dealing with a footer make sure that the item is actually visible (not null and inside the screen either fully or partially.)

更重要的是发表您的code,也许我们就能针对特定的(更好的)解决方案。

Better yet post your code, maybe we will be able to target a specific (better) solution.

这篇关于如何保持在Android的多页脚看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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