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


Java TabHost.addTab方法代码示例

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


在下文中一共展示了TabHost.addTab方法的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: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
private static void addTab(MFBMain activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) {
    // Attach a Tab view factory to the spec
    tabSpec.setContent(activity.new TabFactory(activity));
    String tag = tabSpec.getTag();

    // Check to see if we already have a fragment for this tab, probably
    // from a previously saved state.  If so, deactivate it, because our
    // initial state is that a tab isn't shown.
    tabInfo.fragment = activity.getSupportFragmentManager().findFragmentByTag(tag);
    if (tabInfo.fragment != null && !tabInfo.fragment.isDetached()) {
        FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction();
        ft.detach(tabInfo.fragment);
        ft.commit();
        activity.getSupportFragmentManager().executePendingTransactions();
    }

    tabHost.addTab(tabSpec);
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:19,代码来源:MFBMain.java

示例3: 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

示例4: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setResult(RESULT_CANCELED);
  setContentView(R.layout.folder_picker);

  TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
  tabHost.setup();
  
  tabHost.addTab(tabHost.newTabSpec("t1").setIndicator(getString(R.string.folder_new)).setContent(this));
  tabHost.addTab(tabHost.newTabSpec("t2").setIndicator(getString(R.string.folder_existing)).setContent(this));
  tabHost.setCurrentTab(0);
  tabHost.setOnTabChangedListener(this);

  onTabChanged(null);

  mIconPicker = new IconPicker(this, true);
  mIconSelect = (ImageView) findViewById(R.id.folder_icon);
  mIconSelect.setOnClickListener(this);
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:21,代码来源:FolderPick.java

示例5: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("web1")
            .setContent(this));
    tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("web2")
            .setContent(this));
    tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("web3")
            .setContent(this));
    tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator("web4")
            .setContent(this));
    tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("web5")
            .setContent(this));
    tabHost.addTab(tabHost.newTabSpec("tab6").setIndicator("web6")
            .setContent(this));
}
 
开发者ID:bangqu,项目名称:easyapi-apm-demo,代码行数:18,代码来源:TabWebViewActivity.java

示例6: 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

示例7: onCreateView

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	_viewRoot = inflater.inflate(R.layout.fragment_tabs, null);
       
	_tabHost = (TabHost)_viewRoot.findViewById(android.R.id.tabhost);
       _tabHost.setup();
       
       for (TabDefinition tab : TAB_DEFINITIONS) {
       	_tabHost.addTab(createTab(inflater, _tabHost, _viewRoot, tab));	
       }
       
       return _viewRoot;
}
 
开发者ID:alaskalinuxuser,项目名称:apps_small,代码行数:14,代码来源:TabsFragment.java

示例8: 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

示例9: 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

示例10: 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

示例11: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
private void addTab(String name, int titleId) {
    Intent intent = new Intent(this, WebViewActivity.class);
    intent.putExtra(WebViewActivity.FILENAME, name);
    TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec(name)
            .setIndicator(getString(titleId), getResources().getDrawable(R.drawable.ic_tab_about))
            .setContent(intent));
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:AboutActivity.java

示例12: setupBlotterTab

import android.widget.TabHost; //导入方法依赖的package包/类
private void setupBlotterTab(TabHost tabHost) {
    Intent intent = new Intent(this, BlotterActivity.class);
    intent.putExtra(BlotterActivity.SAVE_FILTER, true);
    intent.putExtra(BlotterActivity.EXTRA_FILTER_ACCOUNTS, true);
    tabHost.addTab(tabHost.newTabSpec("blotter")
            .setIndicator(getString(R.string.blotter), getResources().getDrawable(R.drawable.ic_tab_blotter))
            .setContent(intent));
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:9,代码来源:MainActivity.java

示例13: onCreate

import android.widget.TabHost; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab_browse);
    // local server startup
    upnpClient = UpnpClient.getInstance(getApplicationContext());


    tabHost = (TabHost) findViewById(R.id.browserTabHost);
    tabHost.setup(this.getLocalActivityManager());
    serverTab = tabHost.newTabSpec("server").setIndicator(getResources().getString(R.string.title_activity_server_list), getResources().getDrawable(R.drawable.device_48_48)).setContent(new Intent(this, ServerListActivity.class));
    tabHost.addTab(serverTab);
    contentTab = tabHost.newTabSpec("content").setIndicator(getResources().getString(R.string.title_activity_content_list), getResources().getDrawable(R.drawable.cdtrack)).setContent(new Intent(this, ContentListActivity.class));
    tabHost.addTab(contentTab);
    receiverTab = tabHost.newTabSpec("receiver").setIndicator(getResources().getString(R.string.title_activity_receiver_list), getResources().getDrawable(R.drawable.laptop_48_48)).setContent(new Intent(this, ReceiverListActivity.class));
    tabHost.addTab(receiverTab);
    playerTab = tabHost.newTabSpec("player").setIndicator(getResources().getString(R.string.title_activity_player_list), getResources().getDrawable(R.drawable.player_play)).setContent(new Intent(this, PlayerListActivity.class));
    tabHost.addTab(playerTab);


    // add ourself as listener
    upnpClient.addUpnpClientListener(this);
    if(savedInstanceState != null){
        setCurrentTab(Tabs.valueOf(savedInstanceState.getInt(CURRENT_TAB_KEY, Tabs.CONTENT.ordinal())));
    }else if (upnpClient.getProviderDevice() != null) {
        setCurrentTab(Tabs.CONTENT);

    }
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:30,代码来源:TabBrowserActivity.java

示例14: 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

示例15: addTab

import android.widget.TabHost; //导入方法依赖的package包/类
TabHost.TabSpec addTab(TabHost tabHost, String label, Class activityClass) {
	Intent tabIntent = (new Intent()).setClass(this, activityClass);
	View tabView = createTabView(label);
	TabHost.TabSpec tabSpec = tabHost.newTabSpec(label).setIndicator(tabView).setContent(tabIntent);
	tabHost.addTab(tabSpec);
	return tabSpec;
}
 
开发者ID:dozingcat,项目名称:WireGoggles,代码行数:8,代码来源:MediaTabActivity.java


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