本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
});
}
示例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;
}