我正在開發一個Android應用程序,當應用程序從Web服務中獲取一些數據時,它會在一段時間內顯示一個空白屏幕。我怎樣才能防止這種情況發生?我會很感激幫助。如何增加android應用程序的響應時間?
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);
[見這裏...(http://samir-mangroliya.blogspot.in/p/android-customized-listview.html) – 2012-07-14 09:07:27