我正在开发一个应用程序,它可以从服务中激活对话框。下面是我用来从服务中弹出对话框的代码
private void popPrescriptionEditDialog() {
mReadingHandler.post(new Runnable() {
@Override
public void run() {
LayoutInflater inflater = LayoutInflater.from(context);
final View dialogView = inflater.inflate(R.layout.ble_prescription_edit_dialog, null);
final Dialog dialog = new Dialog(context, R.style.DialogStyle);
btnSave = (TextView) dialogView.findViewById(R.id.btnSave);
btnCancel = (TextView) dialogView.findViewById(R.id.btnCancel);
final EditText etDosageData = (EditText) dialogView.findViewById(R.id.etDosageData) ;
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.getWindow().setType(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
dialog.setContentView(dialogView);
dialog.setCancelable(false);
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
displayToast("Data Saved");
dialog.dismiss();
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
当EditText etDosageData
获得焦点时,对话框必须向上移动并为键盘让路,但对话框不会向上移动。是因为它是系统警报类型对话框吗?任何建议的解决方法?