[英]Android ListView ArrayAdapter notifyDataSetChanged() not always work
我有一個連接到遠程服務器並從中獲取數據的應用程序。
根據此數據,我在ListView連接的對象中進行了一些更改,並且我正在使用notifyDataSetChanged()方法刷新我的ListView並反映我的更改。
不幸的是,該方法並不總是刷新列表。
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();
}
每當我想刷新列表但並不總是這樣做時,就會調用onUpdate()方法。所做的更改是ListView代表的對象內部的屬性更改,但是僅當我重新加載ListView時,更改才刷新
有什么原因嗎?
從顯示的代碼很難看出來,但是setClientsInRangeList()是否有可能實際上沒有打開任何新數據?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.