【问题标题】:How can I keep the input text in webview after orientation change in Android如何在Android中更改方向后将输入文本保留在webview中
【发布时间】:2015-03-26 14:10:53
【问题描述】:

我有一个使用简单 Webview 的 Android 应用程序。网络上有许多输入区域和文本区域。目前,当用户改变移动设备的方向时,所有输入都会被刷出并刷新。如何在方向更改后保留所有这些输入?

我不希望限制用户在使用该应用时只能使用纵向或横向模式。

我已阅读这些问题,但似乎它们不起作用。它们仅与防止重新加载活动有关。

Activity restart on rotation Android Change screen orientation in Android without reloading the activity

非常感谢!

【问题讨论】:

    标签: android webview rotation screen-orientation orientation-changes


    【解决方案1】:

    在你的活动中

    @Override
    
    public void onConfigurationChanged(Configuration newConfig) {
        // TODO Auto-generated method stub
        super.onConfigurationChanged(newConfig);
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            System.out.println("this's landscape");
    
        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
            System.out.println("this's portrait");
        }
    }
    

    在您的清单中(在您的活动标签内)

    android:configChanges="orientation|keyboardHidden|screenSize"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-13
      • 2011-01-18
      • 1970-01-01
      • 2013-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多