如何从一个通用适配器调用notifyDataSetChanged() [英] How to call notifyDataSetChanged() from a generic Adapter

查看:79
本文介绍了如何从一个通用适配器调用notifyDataSetChanged()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 OnItemClickListener 的ListView 有以下方式:

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id)

我想有背后的的ListView 刷新适配器,我相信这是通过使用完成的:

I'd like to have the adapter behind the ListView refresh, and I believe this is done through the use of:

BaseAdapter.notifyDataSetChanged()

我如何使用参数在 onItemClick 的方法来做到这一点?到目前为止,我已经试过:

How do I use the parent parameter in the onItemClick method to do this? So far I've tried:

parent.getAdapter().notifyDataSetChanged();

此抛出一个错误,因为返回的对象是类 HeaderViewListAdapter ,其原因不明不是 BaseAdapter

This throws an error because the object returned is of class HeaderViewListAdapter, which for reasons unknown isn't a subclass of BaseAdapter.

推荐答案

据我所知,还没有在HeaderListView数据刷新/重载任何方法。我能想到这样做的唯一方法是重新分配适配器。

AFAIK, there isn't any method in HeaderListView for data refresh/reload. The only way I can think of doing this is to reassign the adapter.

这篇关于如何从一个通用适配器调用notifyDataSetChanged()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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