Android 键盘不';t出现,弹出窗口出现后,可以单击父视图上的按钮
单击特定按钮后,屏幕上会出现一个弹出窗口。弹出窗口中有一个edittext对象,但我无法写入它,因为键盘没有出现。其次,弹出窗口父视图上的其他按钮仍然可以单击。我怎样才能修好这些?我的代码: 编辑\u text\u popup.xmlAndroid 键盘不';t出现,弹出窗口出现后,可以单击父视图上的按钮,android,Android,单击特定按钮后,屏幕上会出现一个弹出窗口。弹出窗口中有一个edittext对象,但我无法写入它,因为键盘没有出现。其次,弹出窗口父视图上的其他按钮仍然可以单击。我怎样才能修好这些?我的代码: 编辑\u text\u popup.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dip"
android:background="@color/conn_text" >
<EditText
android:id="@+id/editTextInPopup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hello_world"
android:padding="5dip"
android:background="@color/blue3">
</EditText>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:padding="10dip">
<Button
android:id="@+id/popupcommitbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ok"/>
<Button
android:id="@+id/popupcancelbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_alignParentRight="true" />
</RelativeLayout>
</LinearLayout>
AndroidManifest中显示softInputMode的活动标记未隐藏:
<activity
android:name=".GroupConnections"
android:label="@string/app_name" >
</activity>
我也有类似的问题。尝试在manifest.xml中的活动标记中添加此行:
android:windowSoftInputMode="stateVisible"
将弹出对话框更改为活动,在manifest.xml中使用此代码,它是“将活动显示为对话框”,您可以将其作为常规活动启动,但它会显示这样的对话框,这将更容易显示自定义对话框:
<activity
android:name=".view.MyDialog"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible"
android:theme="@android:style/Theme.Dialog" >
</activity>
我在以下链接中找到了解决方案:
添加以下命令
editpopup.setFocusable(true)代码>解决了这两个问题。主窗口上没有edittext obejct,只是在弹出窗口中。所以,在弹出窗口出现之前,若键盘是可见的,那个么它并不是毫无意义的。
<activity
android:name=".view.MyDialog"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible"
android:theme="@android:style/Theme.Dialog" >
</activity>