我正在实现一个android应用程序。我在一项活动中使用网络服务。我正在显示一个进度对话框,直到它加载第二个活动。但它不会一直显示并显示一段时间黑屏。它看起来像应用程序挂起。我应该怎么办?我浪费了我的三天。我正在为这些过程使用 asynctask。请帮我 。
protected void onListItemClick(ListView l, View v, final int position,
long id) {
super.onListItemClick(l, v, position, id);
progressDialog = ProgressDialog.show(ProjectListActivity.this,
"Please wait...", "Loading...");
new Thread() {
public void run() {
try {
String project = titles.get(position - 1);
performBackgroundProcess(project);
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
progressDialog.dismiss();
}
}.start();
}
private void performBackgroundProcess(String project) {
String spaceId = null;
String spaceName = null;
/*
* for (Space space : spaces){
* if(space.getName().equalsIgnoreCase((String) ((TextView)
* v).getText())){ spaceId = space.getId(); } }
*/
for (Space space : spaces) {
if (project.equals(space.getName())) {
newSpace = space;
}
}
spaceId = newSpace.getId();
spaceName = newSpace.getName();
/*
* Intent intent = new Intent(this, SpaceComponentsActivity.class);
* intent.putExtra("spaceId", spaceId); intent.putExtra("tabId", 0);
* intent.putExtra("className", "TicketListActivity"); TabSettings ts =
* new TabSettings(); ts.setSelTab(1); this.startActivity(intent);
*/
Intent intent = new Intent(this, SpaceComponentsActivity.class);
intent.putExtra("spaceId", spaceId);
intent.putExtra("tabId", 0);
intent.putExtra("spaceName", spaceName);
// intent.putExtra("className", "TicketListActivity");
TabSettings ts = new TabSettings();
ts.setSelTab(0);
ts.setSelTabClass("TicketListActivity");
this.startActivity(intent);
/*
* Toast.makeText(getApplicationContext(), ((TextView) v).getText(),
* Toast.LENGTH_SHORT).show();
*/
}