如何处理与活动屏幕方向变化选项卡的活动中开始

编程入门 行业动态 更新时间:2024-10-26 22:26:03
本文介绍了如何处理与活动屏幕方向变化选项卡的活动中开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个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.

更多推荐

如何处理与活动屏幕方向变化选项卡的活动中开始

本文发布于:2023-11-27 01:20:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635983.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何处理   选项卡   屏幕   方向   活动中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!