gpt4 book ai didi

java - 列表 Activity 和对话框

转载 作者:行者123 更新时间:2023-12-02 08:02:58 26 4
gpt4 key购买 nike

我有一个 ListActivity,需要通过Thread 处理大量数据。我想在后台中完成工作时显示一个Dialog。但是,在 View 加载完成之前,Dialog 不会显示。我在常规 activity 上使用这种方法并且它有效(Dialog 弹出,worker 启动,worker 完成,Dialog 关闭)。工作完成后,将向处理程序发送一条消息,以加载 View 并关闭对话框

这是我的代码:

@Override
public void onCreate(Bundle icicle) {

super.onCreate(icicle);
initViewProperties();
dialogCode = 0;
showDialog(dialogCode);

}

@Override
protected Dialog onCreateDialog(int id) {

int resID = getResources().getIdentifier(getCfrFile(), "raw", getPackageName());
progDialog = new ProgressDialog(this);

switch (dialogCode) {
case 0:
progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progDialog.setMessage(getCurrentTitle());
break;
case 1:
progDialog.setMessage("Loading CFR");
break;

default:
break;
}

try {
// do the work here
xmlListRowFactoryHelper = new AcmListViewFactoryHelper(handler, resID, this, xpathBuilder(false), "title") ;
xmlListRowFactoryHelper.run();

} catch (Exception e) {

e.printStackTrace();
}

return progDialog;

}

final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {

int total = msg.getData().getInt("total");

progDialog.setProgress(total);

if (total <= 0){

xmlListRowFactoryHelper.setState(AcmTableRowFactoryHelper.DONE);
// load the view here
loadListView();
}
}
}

最佳答案

关于java - 列表 Activity 和对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8624439/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com