删除页脚视图时,适配器类转换异常? [英] Adapter class cast exception when removing a Footer view?

查看:96
本文介绍了删除页脚视图时,适配器类转换异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个例外,我从来没有想过我会看到。当从一个ListView(原文如此)删除类转换异常适配器的页脚视图。

I have an exception I never thought I would see. A class cast exception of the adapter when removing a footer view from a ListView (sic).

 java.lang.ClassCastException: com.test.MyAdapter
 at android.widget.ListView.removeFooterView(ListView.java:381)

怎么能这样呢?什么是去掉一个页脚都与类转换异常????

How can this happen? What does removing a footer have to do with class cast exception????

该列表是一个多表适配器也许这就是为什么,但仍然是一个类转换异常去除页脚(原文如此)。

The list is a multi-list adapter perhaps that is why but still a class cast exception for removing a footer (sic).

推荐答案

添加您的页脚以的ListView 之前调用 setAdapter()方法。

Add your footer view to ListView before calling setAdapter() method.

补充:

public void addFooterView (View v)

自:API级别1 加一个固定的,以便出现在列表的底部。 如果addFooterView被调用一次以上,该​​意见将会出现在它们被添加的顺序。添加视图使用这种电话可以采取的重点,如果他们想要的。

Since: API Level 1 Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

注:致电setAdapter之前调用此。这是这样的ListView可以包装附带光标一个,也将占到页眉和页脚的看法。

参数 v该视图添加。

<一个href="http://developer.android.com/reference/android/widget/ListView.html#addFooterView%28android.view.View%29">Source

你也可以检查此<一个href="http://stackoverflow.com/questions/4393775/android-classcastexception-when-adding-a-header-view-to-expandablelistview">interesting帖子。

Also you can check this interesting post.

希望这有助于。

这篇关于删除页脚视图时,适配器类转换异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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