【发布时间】:2013-11-08 11:02:34
【问题描述】:
我在线程中使用ProgressDialog。在onButtonClick 中,线程已启动,但当我触摸屏幕上的任何位置时,ProgressDialog 已关闭。
如何防止这种情况发生?
private void ButtonClick(View view) {
btn1 = (Button) view.findViewById(R.id.btn1);
btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
GetStudentData();
}
});
}
private synchronized void GetStudentData() {
try {
// Thread to display loader
new Thread() {
@Override
public void run() {
Looper.prepare();
dialog = Msg.ShowProgressDialogBox(
getActivity(),
dialog,
"Please wait while we fetch the student data...");
Looper.loop();
}
}.start();
new Thread() {
@Override
public void run() {
String studentData="Kailas";
}
}
} catch(Exception ex {
}
}
更新
当我触摸屏幕时,ProgressDialog 会消失,但会获取所有数据。
【问题讨论】:
-
您的问题解决了吗?你的对话进展如何?
-
我使用了 dialog.setCanceledOnTouchOutside(getRetainInstance());这些代码对我来说很好用。
标签: android progressdialog android-progressbar