当我使用AsyncTask时:
class GetStreetName extends AsyncTask<String, Void, JSONObject>
{
ProgressDialog progressDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(getActivity());
progressDialog.setCancelable(true);
progressDialog.setMessage(getString(R.string.dialog_loading));
progressDialog.show();
}
@Override
protected JSONObject doInBackground(String... params) {
// backGround task
}
@Override
protected void onPostExecute(JSONObject result) {
if (result!=null) {
....
progressDialog.dismiss();
enterStreetEditText.requestFocus();
}
}
当我这样做时,在onPostExecute
中关闭对话框时,键盘会被隐藏。如何在对话框解除时阻止此操作并继续显示键盘?
当我不使用ProgressDialog时,问题不会发生。
答案 0 :(得分:0)
它可以帮到你:
@Override
protected void onPostExecute(JSONObject result) {
if (result!=null) {
....
progressDialog.dismiss();
enterStreetEditText.setFocusable(true);
enterStreetEditText.requestFocus();
InputMethodManager imm = (InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE);
imm.showSoftInput(enterStreetEditText , 0);
}
}