您可以使用AsyncTask和ProgressDialog进行此操作
私人ProgressDialog进度;
progress= new ProgressDialog(this);
progress.setIndeterminate(true);
progress.setMessage("I am thinking");
private class MyAsynch extends AsyncTask{
protected void onPreExecute() {
progress.show();
}
@Override
protected String doInBackground(String...strings) { // <== DO NOT TOUCH THE UI VIEW HERE
// TODO Auto-generated method stub
String key= strings[0];
String inString= strings[1];
return encrypt(key, inString); // <== return value String result is sent to onPostExecute
}
protected void onPostExecute(String result){
progress.dismiss();
editTextConfusedText.setText(result); // you could launch results dialog here
}
};
protected void onPause() {
super.onPause();
if (asynch != null) {asynch.cancel(true);}
if (progress != null){progress.cancel();}
}