我正在实现一个android应用程序。我正在一项活动中使用Web服务。我显示一个进度对话框,直到它加载第二个活动。但它并没有显示整个时间,并显示一段时间的黑屏。它看起来像应用程序挂起。我该怎么办?我浪费了我三天的时间。我正在使用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();
*/
}
哪里是你的代码?盲猜你是使用主线程来调用'webService'.use http://developer.android.com/reference/android/os/AsyncTask.html来调用'wed服务'。 – 2012-07-18 06:01:20
我张贴我的代码。 – 2012-07-18 06:03:34
我正在执行performBackgroundProcess方法中的所有逻辑。需要发布它呢?正如M Mohsin Naeem所说的 – 2012-07-18 06:10:23