创建一个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() {
android popwindow输入框与返回键焦点冲突问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
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 R语言Rstudio突然无法启动
- ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
- ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
- ¥15 用windows做服务的同志有吗
- ¥60 求一个简单的网页(标签-安全|关键词-上传)
- ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
- ¥100 为什么这个恒流源电路不能恒流?
- ¥15 有偿求跨组件数据流路径图
- ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值