本文整理汇总了Java中android.widget.TabHost.TabSpec.setContent方法的典型用法代码示例。如果您正苦于以下问题:Java TabSpec.setContent方法的具体用法?Java TabSpec.setContent怎么用?Java TabSpec.setContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TabHost.TabSpec
的用法示例。
在下文中一共展示了TabSpec.setContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_base_clear_cache);
//1.����ѡ�1
TabSpec tab1 = getTabHost().newTabSpec("clear_cache").setIndicator("��������");
// ImageView imageView = new ImageView(this);
// imageView.setBackgroundResource(R.drawable.ic_launcher);
// View view = View.inflate(this, R.layout.test, null);
// TabSpec tab1 = getTabHost().newTabSpec("clear_cache").setIndicator(view);
//2.����ѡ�2
TabSpec tab2 = getTabHost().newTabSpec("sd_cache_clear").setIndicator("sd������");
//3.��֪����ѡ���������
tab1.setContent(new Intent(this,CacheClearActivity.class));
tab2.setContent(new Intent(this,SDCacheClearActivity.class));
//4.��������ѡ�ά��host(ѡ�����)��ȥ
getTabHost().addTab(tab1);
getTabHost().addTab(tab2);
}
示例2: onCreate
import android.widget.TabHost.TabSpec; //导入方法依赖的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);
}
示例3: initTabs
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
private void initTabs() {
MainTab[] tabs = MainTab.values();
final int size = tabs.length;
for (int i = 0; i < size; i++) {
MainTab mainTab = tabs[i];
TabSpec tab = mTabHost.newTabSpec(getString(mainTab.getResName()));
View indicator = inflateView(R.layout.v2_tab_indicator);
ImageView icon = (ImageView) indicator.findViewById(R.id.tab_icon);
icon.setImageResource(mainTab.getResIcon());
TextView title = (TextView) indicator.findViewById(R.id.tab_titile);
title.setText(getString(mainTab.getResName()));
tab.setIndicator(indicator);
tab.setContent(new TabContentFactory() {
@Override
public View createTabContent(String tag) {
return new View(MainActivity.this);
}
});
mTabHost.addTab(tab, mainTab.getClz(), null);
}
}
示例4: createOnePOSTab
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
/** Creates tab with part of entry related to one language and one part of speech,
* runs POS activity.
**/
public void createOnePOSTab(TPage _tpage, TLang _tlang, TLangPOS _lang_pos) {
Bundle b = new Bundle();
b.putInt("page_id", _tpage.getID()); // pass parameter: TPage by page_id
b.putInt("lang_id", _tlang.getID()); // pass parameter: TLang by lang_id
b.putInt("lang_pos_id", _lang_pos.getID()); // pass parameter: TLangPOS by lang_pos_id
Intent i = new Intent(this, WCPOSActivity.class);
i.putExtras(b);
//System.out.println("Source activity: page_id = " + _tpage.getID()
// + "; lang_id = " + _tlang.getID()
// + "; lang_pos_id = " + _lang_pos.getID());
TabSpec _tabspec = tab_host_pos.newTabSpec( "" + _lang_pos.getID() ); // some unique text
_tabspec.setIndicator( getShortPOSText(_lang_pos) );
_tabspec.setContent(i);
tab_host_pos.addTab(_tabspec);
}
示例5: createOneLanguageTab
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
/** Creates tab with part of entry related to one language,
* runs language activity.
**/
public void createOneLanguageTab(TPage _tpage, TLang _tlang) { //TLangPOS _lang_pos) {
Bundle b = new Bundle();
b.putInt("page_id", _tpage.getID()); // pass parameter: TPage by page_id
b.putInt("lang_id", _tlang.getID()); // pass parameter: TLang by lang_id
Intent i = new Intent(this, WCLanguageActivity.class);
//Intent i = new Intent().setClass(this, WCLanguageActivity.class);
i.putExtras(b);
//System.out.println("Source activity: page_id = " + _tpage.getID() + "; lang_id = " + _tlang.getID());
TabSpec _tabspec = tab_host_languages.newTabSpec( "" + _tlang.getID() ); // some unique text
LanguageType _lang = _tlang.getLanguage();
_tabspec.setIndicator(_lang.getCode());
_tabspec.setContent(i);
tab_host_languages.addTab(_tabspec);
}
示例6: initTabs
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
/**
* initializes the pages in the tabbed dialog
*/
protected void initTabs() {
// Setup the tabbed dialog on the layout and add the content of each tab
TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
tabHost.setup();
TabSpec localTabSpec = tabHost.newTabSpec(localTabString());
localTabSpec.setContent(R.id.localGameTab);
localTabSpec.setIndicator(localTabString());
TabSpec remoteTabSpec = tabHost.newTabSpec(remoteTabString());
remoteTabSpec.setContent(R.id.remoteGameTab);
remoteTabSpec.setIndicator(remoteTabString());
tabHost.addTab(localTabSpec);
tabHost.addTab(remoteTabSpec);
// make sure the current tab is the right one
tabHost.setCurrentTab(config.isLocal() ? 0 : 1);
}
示例7: onCreate
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_tabhost);
TabHost tabHost = getTabHost();
TabSpec tabSpec1 = tabHost.newTabSpec("Home");
TabSpec tabSpec2 = tabHost.newTabSpec("Second");
tabSpec1.setIndicator("Home");
tabSpec2.setIndicator("Second");
Intent photosIntent = new Intent(this, GridViewActivity.class);
Intent secondactivIntent = new Intent(this, SecondActivity.class);
tabSpec1.setContent(photosIntent);
tabSpec2.setContent(secondactivIntent);
tabHost.addTab(tabSpec1);
tabHost.addTab(tabSpec2);
}
示例8: initTabs
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
private void initTabs()
{
mTabHost = (TabHost)mView.findViewById(android.R.id.tabhost);
mTabHost.setup();
final TabSpec spec1 = mTabHost.newTabSpec(TAB_TAG_INFO);
spec1.setContent(R.id.color_info_view_tab_info);
spec1.setIndicator(getString(R.string.color_info_tab_info));
final TabSpec spec2 = mTabHost.newTabSpec(TAB_TAG_SIMILAR);
spec2.setContent(R.id.color_info_view_tab_similar);
spec2.setIndicator(getString(R.string.color_info_tab_similar));
mTabHost.addTab(spec1);
mTabHost.addTab(spec2);
}
示例9: onCreate
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab);
TabHost host = (TabHost)findViewById(android.R.id.tabhost);
TabSpec spec = host.newTabSpec("tab1");
spec.setContent(R.id.tab1);
spec.setIndicator("Button1");
host.addTab(spec);
spec = host.newTabSpec("tab2");
spec.setContent(R.id.tab2);
spec.setIndicator("Next Button");
host.addTab(spec);
spec = host.newTabSpec("tab3");
spec.setContent(R.id.tab3);
spec.setIndicator("Just some text");
host.addTab(spec);
}
示例10: createTabSpec
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
@SuppressLint("InflateParams")
private TabSpec createTabSpec(TabHost tabHost, String tag,
Resources res, int labelId, int iconId, Class<?> cls) {
TabSpec spec = tabHost.newTabSpec(tag);
String label = res.getString(labelId);
Drawable icon = res.getDrawable(iconId);
LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.tab, null);
((ImageView) linearLayout.findViewById(R.id.tab_icon)).setImageDrawable(icon);
((TextView) linearLayout.findViewById(R.id.tab_label)).setText(label);
spec.setIndicator(linearLayout);
spec.setContent(new Intent().setClass(this, cls));
return spec;
}
示例11: createTab
import android.widget.TabHost.TabSpec; //导入方法依赖的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;
}
示例12: onCreateView
import android.widget.TabHost.TabSpec; //导入方法依赖的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;
}
示例13: createView
import android.widget.TabHost.TabSpec; //导入方法依赖的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;
}
示例14: addTab
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
public void addTab(TabSpec tabSpec, Class<?> clss, Bundle args) {
tabSpec.setContent(new DummyTabFactory(this.mContext));
String tag = tabSpec.getTag();
TabInfo info = new TabInfo(tag, clss, args);
if (this.mAttached) {
info.fragment = this.mFragmentManager.findFragmentByTag(tag);
if (!(info.fragment == null || info.fragment.isDetached())) {
FragmentTransaction ft = this.mFragmentManager.beginTransaction();
ft.detach(info.fragment);
ft.commit();
}
}
this.mTabs.add(info);
addTab(tabSpec);
}
示例15: newTab
import android.widget.TabHost.TabSpec; //导入方法依赖的package包/类
private TabSpec newTab(String tag, int labelId, int tabContentId) {
Log.d(TAG, "buildTab(): tag=" + tag);
View indicator = LayoutInflater.from(getActivity()).inflate(
R.layout.tab,
(ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
((TextView) indicator.findViewById(R.id.text)).setText(labelId);
TabSpec tabSpec = mTabHost.newTabSpec(tag);
tabSpec.setIndicator(indicator);
Log.d(tag, tabContentId + " tabContentId " + indicator.getId()
+ " indicator get Id ");
tabSpec.setContent(tabContentId);
return tabSpec;
}