本文介绍了操作栏选项卡 - 拥有两个片段(一个是动态的)在一个选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想创建一个显示在左手片段,并在右侧的详细片段列表的标签。当用户点击列表项,右手片段应更改为相应之一。

I am trying to create a tab that displays a list on the left hand fragment and a detailed fragment on the right. When a user clicks a list item, the right hand fragment should change to the appropriate one.

我是新到Android所以我用一个教程,我知道我需要做一些与tablistener:

I am new to android so I used a tutorial and I know I need to do something with the tablistener:

     public static class TabListener implements ActionBar.TabListener
     {
        private final Activity mActivity;
        private final String mTag;
        private final Class mClass;
        private final Bundle mArgs;
        private Fragment mFragment;

什么,我需要将类似Gmail应用,与列表在左边,细节在右边,并保持操作栏(我有标签)之上的另一个很好的例子。

Another good example of what I need would be something like the Gmail app, with a list on the left, detail on the right, and keeping the action bar (mine has tabs) on top.

据我所知,这个监听器膨胀片段的每个选项卡点击,但我怎么一个充气的布局的,有两个片段的呢?

I understand that this listener inflates a fragment for each tab clicked, but how do I inflate a layout that has two fragments in it?

推荐答案

充气布局有两个片段很简单:你只需指定布局类中的每个片段。但你不能混用静态(布局XML定义)和动态片段。我的意思是,你不能动态实例化code一个新的片段,并将其插入一个View容器(例如,一个LinearLayout中)最初填充的是与片段中的XML。

Inflating a layout with two fragments is simple: you just specify the Class of each fragment in the layout. But you can't mix static (layout XML-defined) and dynamic Fragments. By which I mean, you can't dynamically instantiate a new Fragment in code and insert it into a View container (e.g., a LinearLayout) that was originally populated with Fragments in the XML.

这篇关于操作栏选项卡 - 拥有两个片段(一个是动态的)在一个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:01