如何处理与活动屏幕方向变化选项卡的活动中开始 [英] How do I handle screen orientation changes with an activity started within a tab's activity

查看:118
本文介绍了如何处理与活动屏幕方向变化选项卡的活动中开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TabActivity,每个选项卡对应于它自身的活动。在其中的一个,在onCreate方法,我使用startActivityForResult显示一个对话(具体地,凹凸的BumpAPI活性)。

I have a TabActivity, and each Tab corresponds to its own Activity. In one of them, in the onCreate method, I use startActivityForResult to show a dialog (specifically, Bump's BumpAPI activity).

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    bump = new Intent(this, BumpAPI.class);
    bump.putExtra(BumpAPI.EXTRA_API_KEY, API_KEY);
    startActivityForResult(bump, BUMP_API_REQUEST_CODE);
}

的问题是,当屏幕取向的变化,它试图创建选项卡的再次活动,这使得另一个BumpAPI对话框,导致多个堆叠在彼此的顶部。我有一个勾入开始活动取消了previous时,其中一个方向变化?

The problem is that when the screen orientation changes, it tries to create the tab's activity again which makes another BumpAPI dialog, resulting in multiple stacked on top of each other. Do I have a hook into the started activity to cancel the previous one when the orientation changes?

一个解决方法似乎是添加一个按钮,单击该按钮时,启动第二个活动,但增加了不必要的操作。

A workaround seems to be to add a button that when clicked, starts the second activity, but that adds an unnecessary step.

另外,我无法修复屏幕方向整个tabActivity,因为他们中的一些需要打字的用户可能想用自己的物理键盘。

Also, I can't fix the screen orientation for the entire tabActivity because some of them require typing and users may want to use their physical keyboards.

推荐答案

好吧,我理解了它... pretty的简单解决方案。只需添加机器人:configChanges =方向| keyboardHidden在AndroidManifest活动。这告诉它不要重新启动活动这些类型的配置变化。只有合适的,如果你不具备不同的方位不同的布局,但我们很幸运没有。

Ok I figured it out...pretty simple solution. Just add android:configChanges="orientation|keyboardHidden" to the activity in AndroidManifest. That tells it not to restart the activity for those types of config changes. Only appropriate if you don't have separate layouts for the different orientations, but we luckily did not.

这篇关于如何处理与活动屏幕方向变化选项卡的活动中开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆