陌上铭记 2015-12-23 02:11 采纳率: 0%
浏览 2227

android popwindow输入框与返回键焦点冲突问题

创建一个popwindow 弹出一个页面 里面有输入框 如果输入框没有获取焦点点击系统返回键能监听到点击了返回按钮 但是输入框获取焦点后 就监听不到系统返回键了 请大神指教 贴一点核心代码
View popupWindow_view = getLayoutInflater().inflate(R.layout.mydialog_myprice, null, false);
popupWindow = new PopupWindow(popupWindow_view, LayoutParams.MATCH_PARENT,mScreenHight, true);
popupWindow.setFocusable(true);
popupWindow.setAnimationStyle(R.style.popupWindowAnimation);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
//设置动画
WindowManager.LayoutParams params=DetailsPurchaseActivity.this.getWindow().getAttributes();

params.alpha=0.3f;
DetailsPurchaseActivity.this.getWindow().setAttributes(params);
//设置窗口焦点
//设置返回键能够监听事件

popupWindow_view.setFocusable(true);
popupWindow_view.setFocusableInTouchMode(true);
popupWindow_view.setOnKeyListener(new OnKeyListener() {

  • 写回答

1条回答 默认 最新

  • 103style 2015-12-23 08:52
    关注

    final AlertDialog dlg = new AlertDialog.Builder(context).create();
    dlg.show();
    Window window = dlg.getWindow();
    window.setContentView(R.layout.dialog_alter_name);
    window.setGravity(Gravity.CENTER);
    editText = (EditText) window.findViewById(R.id.edit_name);
    editTextNumber = (EditText) window.findViewById(R.id.edit_number);
    editText.setText(datas.get(position).getName());
    editTextNumber.setText(datas.get(position).getPhone());
    Button ok = (Button) window.findViewById(R.id.ok);
    Button cancle = (Button) window.findViewById(R.id.cancel);
    ok.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    if (!editText.getText().toString().equals("")) {
    datas.get(position).setName(editText.getText().toString());
    if (!editTextNumber.getText().toString().equals("")) {
    datas.get(position).setPhone(editTextNumber.getText().toString());
    }
    notifyDataSetChanged();
    }
    dlg.dismiss();
    }
    });
    cancle.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    dlg.dismiss();
    }
    });

    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波