使用vogella教程添加选项卡



我正在开发一个Android应用程序,并且已经编写了一些代码,但是我意识到在某些屏幕之间切换选项卡会很好。

我使用了"导航选项卡"的vogella教程,来自: http://www.vogella.com/tutorials/AndroidActionBar/article.html#actionbar_navigation_tab

现在我遇到了他的问题,我不知道如何将我的内容添加到单个选项卡中。

还尝试了其他标签品种,但这让我更加困惑。即使是安卓开发网站上的标签教程也不是更好的:(

作为安卓编程的新手,我现在需要一些帮助:)

谢谢你的答案

碎裂

选项卡的内容由 Vogella 以不同的片段进行管理。因此,您需要做的是为不同的选项卡创建不同的片段。然后在 FragmentManager 的帮助下单击选项卡后,立即将此片段放入容器中。Vogella 使用以下侦听器来执行此操作:

  @Override
  public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // When the given tab is selected, show the tab contents in the
    // container view.
    Fragment fragment = new DummySectionFragment();
    Bundle args = new Bundle();
    args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
    fragment.setArguments(args);
    getFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
  }

最新更新