當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。