简体   繁体   English

设备旋转后保持键盘状态

[英]Maintain keyboard state after device rotation

I have a chat fragment with a listview and a edittext and i wanna when the user rotate the device, if the keyboard was shown, it still showing. 我有一个带有listview和edittext的聊天片段,我想当用户旋转设备时,如果键盘显示,它仍然显示。 But on my fragment, if the user rotate from landscape to portrait and the keyboard is open, it reapear open. 但是在我的片段上,如果用户从横向旋转到纵向并且键盘处于打开状态,则会重新打开。 But from portrait to landscape, it closes on rotation. 但是从纵向到横向,它在旋转时关闭。 I have no idea what could be and how could i save the keyboard state to recover it. 我不知道可能是什么,我怎么能保存键盘状态来恢复它。 Thanks in advance. 提前致谢。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="vertical" >

<com.example.irclient2.adapter.MyEditText
    android:id="@+id/chatinput"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:imeOptions="actionSend|flagNoExtractUi"
    android:inputType="textCapSentences" />

<ListView
    android:id="@+id/chatlist"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/chatinput"
    android:background="@drawable/fundo_chat"
    android:divider="@android:color/transparent"
    android:dividerHeight="1.0sp"
    android:padding="5dp"
    android:scrollingCache="false"
    android:smoothScrollbar="true"
    android:transcriptMode="normal" >
</ListView>

Try removing/commenting any code you have in your fragment and activity that deals with handling focus and/or the keyboard (to isolate the problem) and try the solution to this question: 尝试删除/评论片段中的任何代码以及处理焦点和/或键盘的活动(以隔离问题)并尝试解决此问题:

Keyboard issues arising on orientation change 方向改变引起的键盘问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM