我创建了一个弹出窗口并为其添加了一个 EditText。但是当我点击文本字段时软键盘不显示。我该怎么做? 谢谢..
最佳答案
我认为您的 xml 中存在一些问题。执行以下操作。
这里是popup.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
xmlns:android="http://schemas.android.com/apk/res/android">
<EditText android:id="@+id/dialogSearchBox"
android:inputType="text"
android:hint="Search"
android:layout_height="40dip"
android:layout_width="fill_parent">
</EditText>
</LinearLayout>
现在您还没有提到您喜欢使用哪种提醒以及您是否喜欢使用任何肯定或否定按钮。
因此,我只是将此布局扩展到警报对话框。
AlertDialog.Builder pop_up = new AlertDialog.Builder(this);
pop_up.setView(this.getLayoutInflater().inflate(R.layout.popup, null));
pop_up.show();
点击编辑文本软键盘显示。试试吧。
关于在 EditText 中点击时不会弹出 Android keyBoard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8415456/