gpt4 book ai didi

android - 如果显示软键盘弹出窗口崩溃

转载 作者:行者123 更新时间:2023-11-29 17:31:11 25 4
gpt4 key购买 nike

我有带有按钮和编辑文本的弹出窗口。然后我触摸编辑文本或使用

InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);keyboard

应用崩溃了。

错误是:java.lang.IllegalArgumentException: 添加窗口后窗口类型不能改变。

代码:

LayoutInflater layoutInflater = (LayoutInflater) getActivity().getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popup_over_map, null);
Context context = this.getActivity().getApplicationContext();
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(metrics);
int displayWidth = metrics.widthPixels;
int displayHeight = metrics.heightPixels;
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(displayWidth - 10, displayHeight - 125);
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
final PopupWindow popupWindow = new PopupWindow(popupView,
layoutParams.width, layoutParams.height, true);
popupWindow.setSoftInputMode(WindowManager.LayoutParams.
SOFT_INPUT_STATE_VISIBLE);

Button btnDismiss = (Button) popupView.findViewById(R.id.close_window_btn);
btnDismiss.setOnClickListener(this);

etTimeUntil = (EditText)popupView.findViewById(R.id.time_et);

checkOnDemand = (CheckBox) popupView.findViewById(R.id.check_ondemand_popup);
....

最佳答案

请检查您的 list ,目标版本应小于 14 或删除目标版本标签....!

<uses-sdk
android:targetSdkVersion="11"/>

我也遇到过这个问题,这对我有用,祝你好运......!

关于android - 如果显示软键盘弹出窗口崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32938546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com