Adapter報錯:The content of the adapter has changed的解決
從DDMS中的log也無法定位到準確的出錯位置,後來仔細檢查下發現,自己在後臺的Background thread中直接呼叫adapter的notifyDataSetChanged()造成的。從網上查詢資料需要將相關程式碼到Handler中處理,即解決此問題。
Handler的定義:
繼承Handler的子類:
//Handler類
private class MyHandler extends Handler{
public MyHandler(){
}
public MyHandler(Looper L){
super(L);
}
//子類重寫此方法
@Override
public void handleMessage(Message msg){
super.handleMessage(msg);
//此處更新UI
if(msg.what==1){
MyAdapter adapter = new MyAdapter();
adapter.notifyDataSetChanged();
listView.setAdapter(adapter);
}
}
}
相關推薦
Adapter報錯:The content of the adapter has changed的解決
The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background
UNION關鍵字報錯:ERROR 1222 (21000): The used SELECT statements have a different number of columns
今天進行總結時,發現這個錯誤,後來,發現這是由於union 造成。 在使用union時,有以下規則。 1.必須由兩條或者兩條以上的select語句組成,語句之間用關鍵字union分隔 2.每
eclipse啟動報錯:Could not create the java virtual machine
報錯 解壓 java 開發 升級 最新 分享 src info 用maven、springboot開發時,安裝了當時最新版的eclipse(3.5.5)。eclipse解壓版的非常方便,想先安裝了看看。暫時沒有升級其他軟件。 打開的時候報錯: 原因其實就是還木有升級新版
TensorFlow測試程式報異常:FutureWarning: Conversion of the second argument of issubdtype from `float` to `np
使用安裝好的tensorflow-gpu 進行程式測試時出現異常: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In futu
npm install總是報錯:unable to verify the first certificate(無法驗證第一證書)
解決方法一: 取消ssl驗證:npm config set strict-ssl false 如果還沒成功,則將npm源更換為國內映象:npm config set registry http://registry.cnpmjs.org/ npm config set registr
使用BouncyCastleProvider類報錯:JCE cannot authenticate the provider BC
java.lang.SecurityException: JCE cannot authenticate the provider BC 當出現這個錯誤,網上一般都是要修改jre/lib/sercure下的檔案的,這個太麻煩了。問題的根源並不是jre的錯,因此沒必要這麼搞。 出現這個
docker報錯:Cannot connect to the Docker daemon. Is the docker daemon running on this host?
docker這種報錯一般情況都是docker未啟動對於這種情況只用重啟docker就行了: service docker restart 還要一種情況則是docker配置檔案出錯按照提示檢視報錯,並找到相應位置進行更改: systemctl status do
PHP 報錯:Deprecated: Methods with the same name as their class will not be constructor...
5.6 name soa 項目 徹底 truct 升級 使用 The 報著個錯的原因是 最近把一個項目從php5.6升級到了php7 報如下錯誤: Deprecated: Methods with the same name as their class will not
部署CM報錯(5):hive配置連線mysql報錯:Able to find the Database server, but not the specified database.
1.問題描述 主機無法連線mysql資料庫,連線報錯 Able to find the Database server, but not the specified database. Please check if the database name is correct and make
The content of the adapter has changed but ListView did not receive a notification的解決方案
在開發過程中,使用ListView時,發現這個錯誤偶爾會出現。特別是做壓力測試的時候,不停的點選重新整理,更容易出現這個錯誤。 在網上找了一下關於這個問題的解決辦法,說的是直接備份一份資料來源,我根據
iOS 報錯:沒有檢視許可權the file "xxx.app" couldn't be opened because you don't have permission to view it.
iOS the file "xxx.app" couldn't be opened because you don't have permission to view it.問題解決方法彙總 (1) 最近重構專案,增加target來區分環境進行差異化編譯配置。 報
解決ListView的The content of the adapter has changed but ListView did not receive a notification崩潰問題
最近在寫一個聚合工具箱的時候,添加了滑動返回功能,使用ListView時(不要問我為啥不用recycleview,小工具嘛,主要是邏輯,頁面都是次要的),遇到如下崩潰問題 java.lang.IllegalStateException: The content of t
mysql啟動報錯:Starting MySQL... ERROR! The server quit without updating PID file
mysql啟動時報錯:Starting MySQL... ERROR! The server quit without updating PID file (/opt/mysql/data/mysql.pid) 的解決方法:1、可能是/opt/mysql/data/資料目錄m
ListView資料來源不同步問題The content of the adapter has changed but ListView did not receive a notification.
最近專案中出現了很多下面的異常: java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Mak
非同步載入Listview The content of the adapter has changed but ListView did not receive a notification
錯誤 The content of the adapter has changed but ListView did not receive a notification 原因 在Android開發過程中,使用了大量的ListView,發現這個錯誤偶爾會出現。特別是做壓力測
(轉)關於Adapter的The content of the adapter has changed問題分析
1 07-28 17:22:02.162: E/AndroidRuntime(16779): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a no
tomcat啟動報錯:Unable to complete the scan for annotations for web application
tomcat啟動報錯,具體報錯資訊如下: Unable to complete the scan for annotations for web application [/Ftrans] due to a StackOverflowError. Possible root
Listview更新資料時崩潰The content of the adapter has changed but did not receive a notification.
說明:在工作中遇到的問題記錄下來,歡迎批評和指正~ 1、問題 在listView上下拉重新整理或者滑動過程中經常碰到這個復現率比較高的崩潰問題 E/AndroidRuntime(16779): j
報錯:failed to get the task for process XXX(解決方案)
引人: iOS真機除錯程式,報如下錯誤資訊: failed to get the task for process XXX 原因: 證書問題,project和targets的證書都必
解決mysql報錯:- Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ'
_for tran contains column schema mysql eat table express mysql執行報錯: - Expression #1 of ORDER BY clause is not in GROUP BY clause and cont