简体   繁体   English

Android ListView ArrayAdapter notifyDataSetChanged()并非始终有效

[英]Android ListView ArrayAdapter notifyDataSetChanged() not always work

I have an application which connect to a remote server and get data from it. 我有一个连接到远程服务器并从中获取数据的应用程序。

According to this data i do some changes in my ListView connected objects and i'm using the notifyDataSetChanged() method to refresh my ListView and reflect my changes. 根据此数据,我在ListView连接的对象中进行了一些更改,并且我正在使用notifyDataSetChanged()方法刷新我的ListView并反映我的更改。

Unfortunately the method not always refresh the list. 不幸的是,该方法并不总是刷新列表。

the onUpdate() supposed to refresh the list. onUpdate()应该刷新列表。

@Override
public void onUpdate() {
    runOnUiThread(updateClientsInRangeRunnable());  
}

private Runnable updateClientsInRangeRunnable()
{
    Runnable run = new Runnable() {

        @Override
        public void run() {
            updateClientsInRangeList(); 
        }
    };
    return run;
}

public void updateClientsInRangeList()
{
    setClientsInRangeList();
    listArrayAdapter.notifyDataSetChanged();
}

the onUpdate() method is called whenever i want to refresh the list but not always it does it... the changes made are property changes inside the objects the ListView represt but the changes doesn't refresh only when i'm reloading the ListView 每当我想刷新列表但并不总是这样做时,就会调用onUpdate()方法。所做的更改是ListView代表的对象内部的属性更改,但是仅当我重新加载ListView时,更改才刷新

is there a reason why ?? 有什么原因吗?

从显示的代码很难看出来,但是setClientsInRangeList()是否有可能实际上没有打开任何新数据?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM