删除页脚视图时,适配器类转换异常?适配器、视图、异常

由网友(怪痞)分享简介:我有一个例外,我从来没有想过我会看到。当从一个ListView(原文如此)删除类转换异常适配器的页脚视图。I have an exception I never thought I would see. A class cast exception of the adapter when removing a fo...

我有一个例外,我从来没有想过我会看到。当从一个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该视图添加。

Source

你也可以检查此interesting帖子。

Also you can check this interesting post.

希望这有助于。

阅读全文

相关推荐

最新文章