应根据要求使用 Android tabhost 或 android 操作栏选项卡

Should use Android tabhost or android action bar tabs based on requirement

我最近开始 android 应用程序开发并开发了我的第一个应用程序。我想开发一个基于选项卡的界面。我不需要使用兼容性库。对于旧版本。

我想要这样的界面:

我知道选项卡 activity 是不推荐使用的东西。所以现在我只剩下两个我知道的选择。操作栏选项卡(http://developer.android.com/guide/topics/ui/actionbar.html#Tabs) or tab host with tab widget as shown in example here: http://android.codeandmagic.org/android-tabs-with-fragments/

在这篇文章的结尾,我读到这种方式已经过时,推荐使用操作栏选项卡方式。但就我而言,除了制表符之外,我还有两个要求:

  1. 我需要 activity 中的另一个公共区域而不是那些选项卡。我不确定操作栏选项卡是否也可以拥有该公共区域。图像中带有编辑文本的区域是地方,我说的是。
  2. 我需要在两个选项卡和父选项卡之间进行通信 activity。

所以我的问题是我应该以哪种方式工作?带有选项卡小部件或操作栏选项卡的选项卡主机。或者我想错了,还有其他更好的方法可以实现这一目标。这个公共区域将是一种日志区域,其中将插入不同的操作并向下滚动。

I don't need to use compatibility lib. for older versions

Android 支持库有很多 "for older versions" 没有的东西。引用 the documentation:

The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs.

这种情况已经持续了大约四年。

I know that tabbed activity is something which is something depreciated

从去年和 Android 5.0 版本开始,操作栏选项卡也已弃用。

So my question is that which way I should work? Tab host with tab widgets or action bar tabs.

可能两者都不是。使用 TabLayoutFragmentTabHostthe many third-party libraries that add tabs to a ViewPager.

中的任何一个

在您引用的两种方法中,TabHost 带有选项卡视图是目前唯一受支持的方法。