在Android的横向和纵向中处理多个标签 [英] Handling multiple tabs during landscape and portrait in android

查看:288
本文介绍了在Android的横向和纵向中处理多个标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经指定使用的布局和布局,土地横向和纵向不同的布局,我的应用程序有多个选项卡。从纵向改为横向或风景人像画面切换到1选项卡中选择,甚至当卡每次都是不同的。我们怎样才能解决这个问题。

I have specified different layouts for landscape and portrait using layout and layout-land, my application have multiple tabs. Each time when changing from portrait to landscape or landscape to portrait screen changes to 1st tab even selected tab is different one. How can we solve this problem.

推荐答案

您可以使用onRetainNonConfigurationInstance()来解决这个问题。

You can use onRetainNonConfigurationInstance() to solve this issue.

public void onCreate(Bundle savedInstanceState)
{
   ....
   lastTab = (Integer) getLastNonConfigurationInstance();
   .....
   if(lastTab != null)
   {
      tabs.setCurrentTab(lastTab);
   }
}

public Object onRetainNonConfigurationInstance() 
{
   return tabs.getCurrentTab();
}

这篇关于在Android的横向和纵向中处理多个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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