简体   繁体   English

Android标签布局设计-最佳方法

[英]Android Tab Layout Design - Best Approach

I'm developing an application and I want to place two activities in a tabbed layout. 我正在开发一个应用程序,我想在选项卡式布局中放置两个活动。 I need the ability for the first activity to send an intent and programmatically switch to the second tabbed activity. 我需要第一个活动能够发送意图并以编程方式切换到第二个选项卡式活动。 This seems possible and is outlined in other posts: 这似乎是可行的,并在其他帖子中对此进行了概述:

Launching activities within a tab in Android 在Android标签中启动活动

However, this approach doesn't seem advisable and it makes use of ActivityGroup, which is now deprecated. 但是,这种方法似乎并不明智,它使用了现已不推荐使用的ActivityGroup。 Can anyone recommend a stable solution that would meet my design needs? 谁能推荐一个可以满足我的设计需求的稳定解决方案?

You may want to take a look at ViewPager from the support library, coupled with https://github.com/JakeWharton/Android-ViewPagerIndicator/blob/master/library/src/com/viewpagerindicator/TabPageIndicator.java 您可能想从支持库中查看ViewPager ,以及https://github.com/JakeWharton/Android-ViewPagerIndicator/blob/master/library/src/com/viewpagerindicator/TabPageIndicator.java

It will produce a tab-like interface that you can swipe through. 它将产生一个类似于选项卡的界面,您可以在其中滑动。 You can explicitly change which tab is being shown by calling viewPager.setCurrentItem(int) . 您可以通过调用viewPager.setCurrentItem(int)显式更改显示哪个选项卡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM