单击按钮后,我正在尝试执行以下操作:
case R.id.bcheckConnection:
if (IPok()) {
PlcState.ErrPlc = false;
Constant.adressIpPlc = adresIp.getText().toString();
final ProgressDialog dialog = ProgressDialog.show(Main.this, "", "Trying to connect...");
new Thread(new Runnable() {
public void run() {
timeout = network.testConnection(Constant.adressIpPlc, 102, 20000);
dialog.dismiss();
}
}).start();
if (timeout > -1) {
PlcState.ErrPlc = false;
stanPolaczenia.setText("Connection established. Timeout = ");
stanTimeout.setText(Long.toString(timeout));
currentIp.setText(Constant.adressIpPlc);
} else {
PlcState.ErrPlc = true;
stanPolaczenia.setText("Error");
stanTimeout.setText("");
currentIp.setText(Constant.adressIpPlc);
}
} else {
Toast.makeText(Main.this, "Wrong IP", Toast.LENGTH_LONG).show();
}
break;
那么是否可以在线程停止运行后更改文本?