当前位置: 首页>>代码示例>>Java>>正文


Java TabHost.newTabSpec方法代码示例

本文整理汇总了Java中android.widget.TabHost.newTabSpec方法的典型用法代码示例。如果您正苦于以下问题:Java TabHost.newTabSpec方法的具体用法?Java TabHost.newTabSpec怎么用?Java TabHost.newTabSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TabHost的用法示例。


在下文中一共展示了TabHost.newTabSpec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
private void addTab(final TabHost host, final int categoryId) {
    final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */);
    final TabHost.TabSpec tspec = host.newTabSpec(tabId);
    tspec.setContent(R.id.emoji_keyboard_dummy);
    final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
            R.layout.emoji_keyboard_tab_icon, null);
    // TODO: Replace background color with its own setting rather than using the
    //       category page indicator background as a workaround.
    iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
    iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
    iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
    tspec.setIndicator(iconView);
    host.addTab(tspec);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:15,代码来源:EmojiPalettesView.java

示例2: initTabHost

import android.widget.TabHost; //导入方法依赖的package包/类
private TabHost initTabHost(LinearLayout view) {
    TabHost host = (TabHost) view.findViewById(R.id.tabHost);
    host.setup();
    //Tab 1
    TabHost.TabSpec spec ;
    spec = host.newTabSpec(getString(R.string.criteria_stateelement_ex1_public));
    spec.setContent(view.findViewById(R.id.tab1).getId());
    spec.setIndicator(getString(R.string.criteria_stateelement_ex1_public));
    host.addTab(spec);
    //Tab 2
    spec = host.newTabSpec(getString(R.string.criteria_stateelement_ex1_private));
    spec.setContent(view.findViewById(R.id.tab2).getId());
    spec.setIndicator(getString(R.string.criteria_stateelement_ex1_private));
    host.addTab(spec);

    return host;
}
 
开发者ID:Orange-OpenSource,项目名称:m-dan,代码行数:18,代码来源:ExStateElmts1Fragment.java

示例3: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTabHost = (TabHost) findViewById(R.id.edit_item_tab_host);
    mTabHost.setup(getLocalActivityManager());

    TabSpec tabCall = mTabHost.newTabSpec("TAB_Call");
    tabCall.setIndicator("电话");
    tabCall.setContent(new Intent(this, AnswerCallActivity.class));
    mTabHost.addTab(tabCall);

    TabSpec tabMessage = mTabHost.newTabSpec("TAB_Message");
    tabMessage.setIndicator("短信");
    tabMessage.setContent(new Intent(this, AnswerMessageActivity.class));
    mTabHost.addTab(tabMessage);

    mTabHost.setCurrentTab(0);
}
 
开发者ID:jp1017,项目名称:AutoAnswerCalls,代码行数:20,代码来源:MainActivity.java

示例4: createTab

import android.widget.TabHost; //导入方法依赖的package包/类
/**
 * Creates a {@link TabSpec} based on the specified parameters.
 * @param inflater The {@link LayoutInflater} responsible for creating {@link View}s.
 * @param tabHost The {@link TabHost} used to create new {@link TabSpec}s.
 * @param root The root {@link View} for the {@link Fragment}.
 * @param tabDefinition The {@link TabDefinition} that defines what the tab will look and act like.
 * @return A new {@link TabSpec} instance.
 */
private TabSpec createTab(LayoutInflater inflater, TabHost tabHost, View root, TabDefinition tabDefinition) {
	ViewGroup tabsView = (ViewGroup)root.findViewById(android.R.id.tabs);
	View tabView = tabDefinition.createTabView(inflater, tabsView);
	 
       TabSpec tabSpec = tabHost.newTabSpec(tabDefinition.getId());
       tabSpec.setIndicator(tabView);
       tabSpec.setContent(tabDefinition.getTabContentViewId());
       return tabSpec;
   }
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:18,代码来源:TabsFragment.java

示例5: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
    super.onCreateView(inflater, container, savedInstanceState);
    
    View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
	tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
	tabHost.setup();
	tabHost.setOnTabChangedListener(this);
	
	for (int i = 0; i < pagerAdapter.getCount(); i++) {
		TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
		//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
		tab.setContent(android.R.id.tabcontent);
		    		    		
		View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
		TextView title = (TextView) indicator.findViewById(android.R.id.title);
		title.setText(pagerAdapter.getPageTitle(i));
		tab.setIndicator(indicator);
		tabHost.addTab(tab);
	}

    viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);
    
    viewPager.setOnPageChangeListener(this);
    setCurrentPosition(0);

	scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
   	viewPager.setCurrentItem(initPageIndex);
	
    return v;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:34,代码来源:QoSTestDetailPagerFragment.java

示例6: createView

import android.widget.TabHost; //导入方法依赖的package包/类
private View createView(View v, LayoutInflater inflater, int currentPage) {
	tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
	tabHost.setup();
	tabHost.setOnTabChangedListener(this);
	
	for (int i = 0; i < pagerAdapter.getCount(); i++) {
		TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
		//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
		tab.setContent(android.R.id.tabcontent);
		    		
		
		View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
		TextView title = (TextView) indicator.findViewById(android.R.id.title);
		title.setText(getActivity().getResources().getStringArray(R.array.result_page_title)[RMBTResultPagerAdapter.RESULT_PAGE_TAB_TITLE_MAP.get(i)]);
		
		if (MAP_INDICATOR_DYNAMIC_VISIBILITY) {
			if (i == RMBTResultPagerAdapter.RESULT_PAGE_MAP) {
				indicator.setVisibility(View.GONE);
			}
		}
		tab.setIndicator(indicator);
		
		tabHost.addTab(tab);
	}
	
	scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
	
    viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
    viewPager.setAdapter(pagerAdapter);
    
    viewPager.setOnPageChangeListener(this);
    setCurrentPosition(currentPage);

    return v;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:36,代码来源:RMBTResultPagerFragment.java

示例7: setupTab

import android.widget.TabHost; //导入方法依赖的package包/类
protected void setupTab(TabHost tabHost, String text, int viewId, int tabId)
{
	View tabview = LayoutInflater.from(tabHost.getContext()).inflate(tabId, null);
	TextView tv = (TextView) tabview.findViewById(R.id.tabText);
	tv.setText(text);

	TabHost.TabSpec tab = tabHost.newTabSpec(text);
	tab.setIndicator(tabview);
	tab.setContent(viewId);
	tabHost.addTab(tab);
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:12,代码来源:DocActivityView.java

示例8: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
	public View onCreateView(final LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = super.onCreateView(inflater, container, savedInstanceState);
		
		final TabHost tabHost = (TabHost) view.findViewById(android.R.id.tabhost);
    	
		tabHost.setup();
//        TabHost.TabSpec spec = tabHost.newTabSpec("Chat");
//        spec.setIndicator("Chat");
//        spec.setContent(new TabHost.TabContentFactory() {
//			@Override
//			public View createTabContent(String tag) {
//				return inflater.inflate(R.layout.game_chat, null);
//			}
//		});
//        tabHost.addTab(spec);

		TabHost.TabSpec spec = tabHost.newTabSpec("Games");
        spec.setIndicator("Games");
        spec.setContent(new TabHost.TabContentFactory() {

            @Override
            public View createTabContent(String tag) {
                return (new Button(getActivity()));
            }
        });
        tabHost.addTab(spec);
        
        return view;
	}
 
开发者ID:eduyayo,项目名称:gamesboard,代码行数:32,代码来源:ContactDetailFragment.java

示例9: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_tab_host, container, false);

    TabHost tabhost = (TabHost) rootView.findViewById(android.R.id.tabhost);
    tabhost.setup();

    TabHost.TabSpec tab1 = tabhost.newTabSpec("tab1");
    tab1.setIndicator("タブ1");
    tab1.setContent(R.id.tab1);
    tabhost.addTab(tab1);

    TabHost.TabSpec tab2 = tabhost.newTabSpec("tab2");
    tab2.setIndicator("タブ2");
    tab2.setContent(R.id.tab2);
    tabhost.addTab(tab2);

    TabHost.TabSpec tab3 = tabhost.newTabSpec("tab3");
    tab3.setIndicator("タブ3");
    tab3.setContent(R.id.tab3);
    tabhost.addTab(tab3);

    tabhost.setCurrentTab(0);

    return rootView;
}
 
开发者ID:yokmama,项目名称:honki_android2,代码行数:28,代码来源:TabHostFragment.java

示例10: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
public static void addTab(TabHost host, String title, int drawable, int index, int layout) {
    TabHost.TabSpec spec = host.newTabSpec("tab" + index);
    spec.setContent(layout);
    View view = prepareTabView(host.getContext(), title, drawable);
    TabsUtil.setTabIndicator(spec, title, host.getContext().getResources().getDrawable(drawable), view);
    host.addTab(spec);
}
 
开发者ID:Kamshak,项目名称:foursquared,代码行数:8,代码来源:TabsUtil.java

示例11: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    rootView= inflater.inflate(R.layout.fragment_first_aid, container, false);



    viewPager = (ViewPager) rootView.findViewById(R.id.view_pager);
    List<Fragment> listFragments = new ArrayList<Fragment>();
    listFragments.add(new BurnsFragment());
    listFragments.add(new CprFragment());
    listFragments.add(new Fragment3());

    viewPager.setOffscreenPageLimit(listFragments.size());

    MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(getFragmentManager(),listFragments);
    viewPager.setAdapter(myFragmentPagerAdapter);
    viewPager.setOnPageChangeListener(this);
    tabHost = (TabHost) rootView.findViewById(R.id.tabHost);
    tabHost.setup();

    String[] tabNames = {"Burns", "CPR", "Fire"};
    for(int i=0; i<tabNames.length; i++){
        TabHost.TabSpec tabSpec;
        tabSpec = tabHost.newTabSpec(tabNames[i]);
        tabSpec.setIndicator(tabNames[i]);
        tabSpec.setContent(new FakeContent(getActivity().getApplicationContext()));
        tabHost.addTab(tabSpec);
    }
    tabHost.setOnTabChangedListener(this);

    return rootView;
}
 
开发者ID:DamianPilot382,项目名称:Health-App,代码行数:34,代码来源:FirstAidFragment.java

示例12: setupTabs

import android.widget.TabHost; //导入方法依赖的package包/类
private void setupTabs(TabHost host) {
    host.setup();
    TabHost.TabSpec spec;

    // Set up titles
    int[] tabContents = new int[]{R.id.addEditItemTab0, R.id.addEditItemTab1, R.id.addEditItemTab2, R.id.addEditItemTab3, R.id.addEditItemTab4, R.id.addEditItemTab5};

    for (int i = -1; ++i < Constants.TAB_TITLES.length; ) {
        //Tabs
        spec = host.newTabSpec(Constants.TAB_TITLES[i]);
        spec.setContent(tabContents[i]);
        spec.setIndicator(Constants.TAB_TITLES[i]);
        host.addTab(spec);
        ((TextView) host.getTabWidget().getChildAt(i).findViewById(android.R.id.title)).setAllCaps(false);
    }

    // Apply the right style
    TabWidget widget = host.getTabWidget();
    for(int i = 0; i < widget.getChildCount(); i++) {
        View v = widget.getChildAt(i);

        // Look for the title view to ensure this is an indicator and not a divider.
        TextView tv = (TextView)v.findViewById(android.R.id.title);
        if(tv == null) {
            continue;
        }
        v.setBackgroundResource(R.drawable.tab_indicator_ab_green);
    }
}
 
开发者ID:davidcampelo,项目名称:PublicOpenSpaceToolApp,代码行数:30,代码来源:PublicOpenSpaceAddEditFragment.java

示例13: createTabSpec

import android.widget.TabHost; //导入方法依赖的package包/类
public TabSpec createTabSpec(TabHost tabHost) {
	TabSpec tabSpec = tabHost.newTabSpec(name);
	
	tabSpec.setContent(new TabContentFactory() {

           @Override
           public View createTabContent(String tag) {
           	return view;
           }
       });
       
       tabSpec.setIndicator(label);
       
	return tabSpec;
}
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:16,代码来源:Tab.java

示例14: createTabs

import android.widget.TabHost; //导入方法依赖的package包/类
private void createTabs(final TabHost tabHost, int grid, int scroll) {
    tabHost.setup();
    // Set divider only works if called before adding the tabs
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        tabHost.getTabWidget().setShowDividers(TabWidget.SHOW_DIVIDER_MIDDLE);
        tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider_dark);
    } else {
        tabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);
    }

    for (int index = TextAdapter.INFO_PREV + 1; index < TextAdapter.INFO_NEXT; index++) {
        switch (index) {
            case TextAdapter.INFO_ARRIVALS:
            TabSpec spec = tabHost.newTabSpec("arrivals");
            // Set the content of the tab
            spec.setIndicator(createSingleTab(R.string.info_arrivals));
            // Set the content of the framelayout when this tab is selected
            spec.setContent(grid);
            tabHost.addTab(spec);
            break;

            case TextAdapter.INFO_FLEETS:
            spec = tabHost.newTabSpec("fleets");
            spec.setIndicator(createSingleTab(R.string.info_fleets));
            spec.setContent(grid);
            tabHost.addTab(spec);
            break;

            case TextAdapter.INFO_STATS:
            spec = tabHost.newTabSpec("stats");
            spec.setIndicator(createSingleTab(R.string.info_stats));
            spec.setContent(scroll);
            tabHost.addTab(spec);
            break;

            case TextAdapter.INFO_THREATS:
            spec = tabHost.newTabSpec("threats");
            spec.setIndicator(createSingleTab(R.string.info_threats));
            spec.setContent(grid);
            tabHost.addTab(spec);
            break;
        }
    }
    tabHost.setCurrentTab(mStateInfoTab);

    InfoView tabContent = (InfoView) tabHost.findViewById(android.R.id.tabcontent);
    tabContent.setEventListener(new IEventListenerInfoView() {
        @Override
        public void onSingleTap() {
            setInfoTab(TextAdapter.INFO_NEXT);
        }
        @Override
        public void onLongPress() {
            // InfoTab changed to stop animations on long press
            if (mExpandedInfoTab) {
                toggleExpandedLayout();
            }
            if (mStateInfoTab != TextAdapter.INFO_FLEETS && mStateInfoTab != TextAdapter.INFO_STATS) {
                setInfoTab(TextAdapter.INFO_STATS);
            }
        }
        @Override
        public void onFling(){
            toggleExpandedLayout();
        }
    });

}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:69,代码来源:GameActivity.java

示例15: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
 public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
 {
     if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_QOS_RESULTS)) {
     	try {
	setQoSResult(new QoSServerResultCollection(new JSONArray(savedInstanceState.getString(BUNDLE_QOS_RESULTS))));
	setDetailType(DetailType.valueOf(savedInstanceState.getString(BUNDLE_DETAIL_TYPE)));
} catch (JSONException e) {
	//e.printStackTrace();
}
     }
     //DetailType detailType = DetailType.valueOf(args.getString(ARG_DETAIL_TYPE));
     pagerAdapter = new QoSCategoryPagerAdapter((RMBTMainActivity) getActivity(), handler, results);
     
     View v = inflater.inflate(R.layout.result_tabhost_pager, container, false);
 	tabHost = (TabHost) v.findViewById(android.R.id.tabhost);
 	tabHost.setup();
 	tabHost.setOnTabChangedListener(this);
 	
 	for (int i = 0; i < pagerAdapter.getCount(); i++) {
 		TabSpec tab = tabHost.newTabSpec(String.valueOf(i));
 		//tab.setIndicator(getActivity().getResources().getStringArray(R.array.result_page_title)[i]);
 		tab.setContent(android.R.id.tabcontent);
 		    		    		
 		View indicator = inflater.inflate(R.layout.tabhost_indicator, null);
 		TextView title = (TextView) indicator.findViewById(android.R.id.title);
 		title.setText(pagerAdapter.getPageTitle(i));
 		tab.setIndicator(indicator);
 		tabHost.addTab(tab);
 	}

     viewPager = (ExtendedViewPager) v.findViewById(R.id.pager);
     viewPager.setAdapter(pagerAdapter);
     
     viewPager.setOnPageChangeListener(this);
     setCurrentPosition(0);

 	scroller = (HorizontalScrollView) v.findViewById(R.id.tabwidget_scrollview);
 	

     if (initPosition != null) {
     	viewPager.setCurrentItem(initPosition);
     }
 	
     return v;
 }
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:47,代码来源:QoSCategoryPagerFragment.java


注:本文中的android.widget.TabHost.newTabSpec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。