[英]Unable to show progress bar before displaying data into listview inside Dialog
[英]Show Progress Dialog before loading ListView contents
我正在從文件中讀取數據 - >保存到數據庫 - >通過從數據庫中提取數據來加載我的自定義ListView ..在獲取和保存數據到數據庫時我想在我的屏幕上顯示ProgressDialog我嘗試了這兩種類型,但它不是工作的
類型1:
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing...");
// importing data from file
// Saving data to the DB
alertDialog.dismiss();
類型2:
UiDialog uiDialog = new UiDialog(CommoditiesListScreen.this);
CommoditiesListScreen.this.runOnUiThread(uiDialog);
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing...");
alertDialog.getWindow().makeActive();
// importing data from file
// Saving data to the DB
uiDialog.stopDialog();
alertDialog.dismiss();
我嘗試了兩種方式它不工作,ProgressDialog沒有出現在屏幕上,我添加的任何其他東西或我在我的鱈魚eplease做的任何修改幫助我...
注意:Forgot call dismiss(); 在ListView加載后出現類型1進度,它旋轉無限時間..
這是使用AsyncTask
的理想情況,您可以在方法onPreExecute()
顯示dialog
,在方法onPreExecute()
中執行后台操作(從文件讀取數據 - >保存到DB doInBackground()
並加載並顯示列表onPostExecute()
方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.