我使用以下代码显示单击TextView时的进度对话框:
contacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new ProgressDialog(GroupChatActivity.this);
dialog.setMessage("Loading Contacts...");
dialog.show();
Toast.makeText(getApplicationContext(), "Contacts Clicked", Toast.LENGTH_SHORT).show();
popupWindow.dismiss();
ArrayList<Bean_PhoneNumbers> listBeanPhone = getContactsFromPhone();
Intent intent = new Intent(GroupChatActivity.this, PhoneBookActivity.class);
//intent.putExtra("listBeanPhone", listBeanPhone);
intent.putParcelableArrayListExtra("listBeanPhone", listBeanPhone);
intent.putExtra("GroupRoomID", roomID);
Log.e("rID", roomID);
startActivity(intent);
}
});
当活动被销毁时,ProgressDialog被解雇。
protected void onDestroy() {
super.onDestroy();
dialog.dismiss();
}
但点击联系人时,“进度”对话框不会立即显示,需要花费太多时间。请帮我解决问题。
答案 0 :(得分:0)
尝试这样。在Listener
之外初始化对话框 dialog = new ProgressDialog(GroupChatActivity.this);
dialog.setMessage("Loading Contacts...");
ArrayList<Bean_PhoneNumbers> listBeanPhone = getContactsFromPhone();
contacts.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.show();
Toast.makeText(getApplicationContext(), "Contacts Clicked", Toast.LENGTH_SHORT).show();
popupWindow.dismiss();
Intent intent = new Intent(GroupChatActivity.this, PhoneBookActivity.class);
//intent.putExtra("listBeanPhone", listBeanPhone);
intent.putParcelableArrayListExtra("listBeanPhone", listBeanPhone);
intent.putExtra("GroupRoomID", roomID);
Log.e("rID", roomID);
startActivity(intent);
}
});