TabHost将包添加到片段

时间:2016-03-03 12:43:58

标签: android android-tabhost

我有像这样配置的tabhost:

private void initialiseTabHost(Bundle args) {
        mTabHost.setup();
        TabInfo tabInfo;
        addTab(this, mTabHost, mTabHost.newTabSpec(getResources().getString(R.string.tab_community_deals)).setIndicator(getResources().getString(R.string.tab_community_deals)), (tabInfo = new TabInfo(getResources().getString(R.string.tab_community_deals), WishlistFragment_.class, args)));
        mapTabInfo.put(tabInfo.getTag(), tabInfo);
        addTab(this, mTabHost, mTabHost.newTabSpec(getResources().getString(R.string.tab_community_rewards)).setIndicator(getResources().getString(R.string.tab_community_rewards)), (tabInfo = new TabInfo(getResources().getString(R.string.tab_community_rewards), WishlistFragment_.class, args)));
        mapTabInfo.put(tabInfo.getTag(), tabInfo);
        mTabHost.setOnTabChangedListener(this);
    }

   private static void addTab(DetailCommunityFragment fragment, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
        tabSpec.setContent(fragment.new TabFactory(fragment.getActivity()));
        tabHost.addTab(tabSpec);
    }

 class TabFactory implements TabHost.TabContentFactory {
        private final Context mContext;

        public TabFactory(Context context) {
            mContext = context;
        }

        public View createTabContent(String tag) {
            View v = new View(mContext);
            v.setMinimumWidth(0);
            v.setMinimumHeight(0);
            return v;
        }
    }

现在我知道我可以通过bundle传递参数了。唯一的事情是在addTab方法中我不知道如何将tabInfo添加到tabhost以便传递包。

有人可以帮助我吗?

0 个答案:

没有答案
相关问题