我的ProgressDialog
没有显示。
以下是代码:
et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
performSearch();
return true;
}
return false;
}
private void performSearch() {
ProgressDialog pd = null;
pd = ProgressDialog.show(MainActivity.this, "Buscando...",
"Buscando " + et.getText() + " en GuiaColor");
lv.setAdapter(new SearchAdapter(MainActivity.this, handler
.search(et.getText().toString(), 20)));
pd.dismiss();
}
});
它工作正常,唯一的问题是Dialog没有出现。
答案 0 :(得分:0)
尝试使用以下代码在后台线程中进行查询,并在任务完成后关闭对话框:
private void performSearch() {
final ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "Buscando...", "Buscando " + et.getText() + " en GuiaColor");
new Thread() {
public void run() {
lv.setAdapter(new SearchAdapter(MainActivity.this, handler.search(et.getText().toString(), 20)));
dialog.dismiss();
}
}.start();
}