我想在线程尝试建立连接时显示此对话框,但是当我按下启动此方法的按钮时,该对话框不会显示。
public void add_mpd(View view) {
dialog = ProgressDialog.show(MainActivity.this, "", "Trying to connect...");
new Thread(new Runnable() {
public void run() {
try {
String child;
EditText new_mpd = (EditText) findViewById(R.id.new_mpd);
child = new_mpd.getText().toString();
mpd = new MPD(child);
children.get(1).add(child);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (MPDConnectionException e) {
e.printStackTrace();
}
}
}
).start();
adapter.notifyDataSetChanged();
dialog.dismiss();
}