我需要显示进度消息给用户。但我无法显示。这里是我的代码。我的代码出了什么问题。指导我做。如何在Android中显示进度对话框?
public class MyProgressDemo extends Activity {
/** Called when the activity is first created. */
private Button clickBtn;
public ProgressDialog progressDialog;
Handler handler = new Handler();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
clickBtn = (Button) findViewById(R.id.Button01);
clickBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
progressDialog = ProgressDialog.show(MyProgressDemo.this, "",
"Please Wait");
processThread();
}
});
}
protected void processThread() {
handler.post(new Runnable() {
@Override
public void run() {
longTimeMethod();
UI();
progressDialog.dismiss();
}
});
}
private void longTimeMethod() {
try {
String strMethod = "MethodName";
String strUrl = "url";
String strResponse = WebserviceCall.Mobileaappstore(strUrl,
strMethod);
Log.d("RES", strResponse);
} catch (Exception e) {
Log.e("Exc", e.getMessage());
}
}
private void UI() {
TextView tv = new TextView(this);
tv.setText("This is new UI");
setContentView(tv);
}
}
感谢您的亲切帮助! – RMK 2010-12-18 06:48:18