【问题标题】:Maintain keyboard state after device rotation设备旋转后保持键盘状态
【发布时间】:2014-08-20 23:06:50
【问题描述】:

我有一个带有列表视图和编辑文本的聊天片段,我想当用户旋转设备时,如果显示键盘,它仍然显示。 但是在我的片段上,如果用户从横向旋转到纵向并且键盘是打开的,它会重新打开。但是从纵向到横向,它会在旋转时关闭。 我不知道可能是什么以及如何保存键盘状态来恢复它。 提前致谢。

<?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>

【问题讨论】:

  • 您可以尝试在 onSavedinstanceState 包中传递一个布尔变量,并以编程方式显示和隐藏键盘
  • 如何检测这个布尔变量?你可以发布一个例子吗?我已经尝试过但没有成功
  • 您找到任何解决方案了吗?

标签: android rotation keyboard fragment


【解决方案1】:

尝试删除/注释您在片段和活动中处理焦点和/或键盘(以隔离问题)的任何代码,并尝试解决此问题:

Keyboard issues arising on orientation change

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-15
    • 1970-01-01
    • 2015-03-03
    相关资源
    最近更新 更多