Java 类android.widget.TabHost 实例源码
项目:mupdf-android-viewer-nui
文件:DocActivityView.java
public void onShowSearch()
{
// "deselect" all the visible tabs by selecting the hidden (first) one
TabHost tabHost = (TabHost)findViewById(R.id.tabhost);
tabHost.setCurrentTabByTag("HIDDEN");
// show search as selected
showSearchSelected(true);
// hide all the other tabs
hideAllTabs();
// show the search tab
findViewById(R.id.searchTab).setVisibility(View.VISIBLE);
mSearchText.getText().clear();
}
项目:TinyPlanetMaker
文件:TabFragment.java
private void createRotateTab(final LayoutInflater inflater, final ViewGroup container, final SeekBar.OnSeekBarChangeListener listener) {
TabHost.TabSpec spec;
spec = mTabHost.newTabSpec(getString(R.string.rotate_tab));
spec.setIndicator(createTabView(inflater, container, getString(R.string.rotate_title)));
spec.setContent(new TabHost.TabContentFactory() {
@Override
public View createTabContent(String tag) {
View view = inflater.inflate(R.layout.fragment_rotate, container, false);
mRotateSeekBar = (RangeSeekBar) view.findViewById(R.id.rotate_seekBar);
mRotateSeekBar.setRange(getResources().getIntArray(R.array.angle_seekbar_values));
mRotateSeekBar.setOnSeekBarChangeListener(listener);
return (view);
}
});
mTabHost.addTab(spec);
}
项目:TinyPlanetMaker
文件:TabFragment.java
private void createWarpTab(final LayoutInflater inflater, final ViewGroup container, final SeekBar.OnSeekBarChangeListener listener) {
TabHost.TabSpec spec = mTabHost.newTabSpec(getString(R.string.warp_tab));
spec.setIndicator(createTabView(inflater, container, getString(R.string.warp_title)));
spec.setContent(new TabHost.TabContentFactory() {
@Override
public View createTabContent(String tag) {
View view = inflater.inflate(R.layout.fragment_warp, container, false);
mWarpSeekBar = (RangeSeekBar) view.findViewById(R.id.warp_seekBar);
mWarpSeekBar.setRange(getResources().getIntArray(R.array.size_seekbar_values));
mWarpSeekBar.setOnSeekBarChangeListener(listener);
return (view);
}
});
mTabHost.addTab(spec);
}
项目:MyFlightbookAndroid
文件:MFBMain.java
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);
}
项目:V2I-Traffic-Light-Demonstrator
文件:PedestrianTab.java
@Override
public void onClick(View view) {
if (AppData.getInstance().hasUserSetServerData()) {
switch (view.getId()) {
case btnEmergency:
sendCommandToRestService("normal");
break;
case btnRequestGreenLong:
sendCommandToRestService("extended");
break;
}
TabHost host = (TabHost) getActivity().findViewById(android.R.id.tabhost);
host.setCurrentTab(1); //1 = PedestrianTab
} else {
final TextView textView = (TextView) this.view.findViewById(R.id.txtView_ErrorMsg);
textView.setText("set/apply REST server ip:port");
}
}
项目:zabbkit-android
文件:FixedFragmentTabHost.java
public final void addTab(final TabHost.TabSpec tabSpec,
final Class<?> clss, final Bundle args) {
tabSpec.setContent(new DummyTabFactory(mContext));
String tag = tabSpec.getTag();
TabInfo info = new TabInfo(tag, clss, args);
if (mAttached) {
// If we are already attached to the window, then check to make
// sure this tab's fragment is inactive if it exists. This shouldn't
// normally happen.
info.fragment = mFragmentManager.findFragmentByTag(tag);
if (info.fragment != null && !info.fragment.isDetached()) {
FragmentTransaction ft = mFragmentManager.beginTransaction();
ft.detach(info.fragment);
ft.commit();
}
}
mTabs.add(info);
addTab(tabSpec);
}
项目:AOSP-Kayboard-7.1.2
文件:EmojiPalettesView.java
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);
}
项目:ssj
文件:TabHandler.java
public TabHandler(Activity activity)
{
this.activity = activity;
tabHost = (TabHost) activity.findViewById(R.id.id_tabHost);
if (tabHost != null)
{
tabHost.setup();
//canvas
canvas = new Canvas(this.activity);
firstTabs.put(canvas, getTabSpecForITab(canvas));
//console
console = new Console(this.activity);
firstTabs.put(console, getTabSpecForITab(console));
//init tabs
canvas.init(new PipeListener()
{
@Override
public void viewChanged()
{
checkAdditionalTabs();
}
});
console.init();
}
}
项目:ssj
文件:TabHandler.java
private void checkVisualFeedbackTabs()
{
List<Component> visualFeedbacks = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.EventHandler, VisualFeedback.class);
removeComponentsOfClass(additionalTabs, VisualFeedback.class);
if (!visualFeedbacks.isEmpty())
{
boolean anyUnmanaged = false;
TableLayout visualFeedbackLayout = getTableLayoutForVisualFeedback(visualFeedbacks);
TabHost.TabSpec newTabSpec = getNewTabSpec(visualFeedbackLayout, visualFeedbacks.get(0).getComponentName(), android.R.drawable.ic_menu_compass); // TODO: Change icon.
for (Component visualFeedback : visualFeedbacks)
{
boolean isManaged = PipelineBuilder.getInstance().isManagedFeedback(visualFeedback);
if(! isManaged)
{
anyUnmanaged = true;
((VisualFeedback) visualFeedback).options.layout.set(visualFeedbackLayout);
}
}
if(anyUnmanaged)
additionalTabs.put(visualFeedbacks.get(0), newTabSpec);
}
}
项目:ssj
文件:TabHandler.java
private void checkCameraPainterTabs()
{
List<Component> cameraPainters = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.Consumer, CameraPainter.class);
removeObsoleteComponentsOfClass(additionalTabs, cameraPainters, CameraPainter.class);
for (Component cameraPainter : cameraPainters)
{
if (additionalTabs.containsKey(cameraPainter))
{
continue;
}
SurfaceView surfaceView = ((CameraPainter) cameraPainter).options.surfaceView.get();
if (surfaceView == null)
{
surfaceView = new SurfaceView(activity);
((CameraPainter) cameraPainter).options.surfaceView.set(surfaceView);
}
TabHost.TabSpec tabSpec = getNewTabSpec(surfaceView, cameraPainter.getComponentName(), android.R.drawable.ic_menu_camera);
additionalTabs.put(cameraPainter, tabSpec);
}
}
项目:ssj
文件:TabHandler.java
private void checkAnnotationTabs()
{
List<Component> iFileWriters = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.Consumer, IFileWriter.class);
List<Component> trainers = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.Consumer, Trainer.class);
if (iFileWriters.isEmpty() && trainers.isEmpty())
{
removeComponentsOfClass(firstTabs, AnnotationTab.class);
}
else if (!containsOfClass(firstTabs, AnnotationTab.class))
{
AnnotationTab annotationTab = new AnnotationTab(activity);
TabHost.TabSpec annotationTabSpec = getTabSpecForITab(annotationTab);
firstTabs.put(annotationTab, annotationTabSpec);
}
else //Annotation tab is already here, refresh it
{
getAnnotation().syncWithModel();
}
}
项目:E621Mobile
文件:ImageFullScreenActivity.java
private void retrieveImage(final ImageNavigator imageNav)
{
if(mShareActionProvider != null)
{
setShareIntent(shareIntent());
}
new Thread(new Runnable()
{
@Override
public void run()
{
try
{
lastImg = e621.post__show(imageNav.getId());
updateImage(lastImg,(TabHost)findViewById(R.id.tabHost));
} catch (IOException e)
{
e.printStackTrace();
updateImage(e621.localGet(imageNav.getId()),(TabHost)findViewById(R.id.tabHost));
}
}
}).start();
}
项目:E621Mobile
文件:ImageFullScreenActivity.java
private void updateDownload(final E621Image img, final TabHost tabHost)
{
ImageView saveButton = (ImageView)tabHost.findViewById(R.id.saveButton);
downloadEventManager = new DownloadEventManager(saveButton);
saveButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
download(img);
}
});
new Thread(new Runnable()
{
@Override
public void run()
{
e621.bindDownloadState(img.id,downloadEventManager);
}
}).start();
}
项目:E621Mobile
文件:ImageFullScreenActivity.java
public void hideUI()
{
getWindow().getDecorView().setSystemUiVisibility(getUIInvisible());
final TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
final int height = getHeight();
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t)
{
final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tabHost.getLayoutParams();
params.setMargins(0,(int) (height * ((1-TABS_HEIGHT) + (interpolatedTime*TABS_HEIGHT))),0,0);
tabHost.setLayoutParams(params);
}
};
a.setDuration(300);
tabHost.startAnimation(a);
tabHost.invalidate();
visible = false;
}
项目:RTP-API-Gradle-Maven-Android-File-Selector-Java
文件:MyFileActivity.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_my_files, container, false);
myFileList = (ListView) v.findViewById(R.id.myFileList);
myFileList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
myFileList.setOnItemClickListener(this);
allEntities = FileSelectHelper.getFileEntities(FileSelectorActivity.getServerResponse());
// Init tab host categories {My files}
tabHostMyFile = (TabHost) v.findViewById(R.id.tabHostMyFiles);
tabHostMyFile.setup();
initTabHost(tabHostMyFile, getMyFilesCategories(allEntities));
tabHostMyFile.setOnTabChangedListener(new MyFilesCategoriesListener());
myFileList.setAdapter(getArrayAdapterForMyFiles(allEntities, tabHostMyFile.getCurrentTabTag()));
FileEntity currentEntity = FileSelectorActivity.getCurrentEntity();
tabHostMyFile.setCurrentTab(currentTab);
FileSelectorActivity.setCurrentEntity(currentEntity);
return v;
}
项目:ktball
文件:BaseBottomNavigationFrame.java
/**
* 初始化组件
*/
protected void initView(Bundle savedInstanceState) {
setContentView(R.layout.layout_bottomnavigation);
mTabHost = (MyFragmentTabHost) findViewById(R.id.tabhost);
//实例化布局对象
//实例化TabHost对象,得到TabHost
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mTabHost.getTabWidget().setDividerDrawable(null);
//得到fragment的个数
int count = getFragmentArray().length;
for (int i = 0; i < count; i++) {
//为每一个Tab按钮设置图标、文字和内容
TabHost.TabSpec tabSpec = mTabHost.newTabSpec(getTextviewArray()[i]).setIndicator(getTabItemView(i));
//将Tab按钮添加进Tab选项卡中
mTabHost.addTab(tabSpec, getFragmentArray()[i], null);
//设置Tab按钮的背景
mTabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.color.white);
}
}
项目:RobotCA
文件:HelpFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (view == null) {
view = inflater.inflate(R.layout.fragment_help, container, false);
TabHost mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
mTabHost.setup();
ViewPager mViewPager = (ViewPager) view.findViewById(R.id.pager);
TabsAdapter mTabsAdapter = new TabsAdapter(getActivity(), mTabHost, mViewPager);
// Here we load the content for each tab.
mTabsAdapter.addTab(mTabHost.newTabSpec("one").setIndicator("Setup"), PageOneFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("two").setIndicator("Using"), PageTwoFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("three").setIndicator("FAQ"), PageThreeFragment.class, null);
}
return view;
}
项目:Li-MVPArms
文件:FragmentTabHost.java
public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
tabSpec.setContent(new DummyTabFactory(mContext));
String tag = tabSpec.getTag();
TabInfo info = new TabInfo(tag, clss, args);
if (mAttached) {
// If we are already attached to the window, then check to make
// sure this tab's fragment is inactive if it exists. This shouldn't
// normally happen.
info.fragment = mFragmentManager.findFragmentByTag(tag);
if (info.fragment != null && !info.fragment.isDetached()) {
FragmentTransaction ft = mFragmentManager.beginTransaction();
// ft.detach(info.fragment);
ft.hide(info.fragment);
ft.commitAllowingStateLoss();
}
}
mTabs.add(info);
addTab(tabSpec);
}
项目:faims-android
文件:FileGalleryPreviewDialog.java
public void addCameraPreview(final View view) {
TabHost.TabSpec tab = tabHost.newTabSpec("camera_preview");
tab.setIndicator("Image Preview");
tab.setContent(new TabContentFactory() {
@Override
public View createTabContent(String tag) {
ScrollView scrollView = new ScrollView(getContext());
LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL);
scrollView.addView(layout);
layout.addView(view);
return scrollView;
}
});
tabHost.addTab(tab);
}
项目:faims-android
文件:FileGalleryPreviewDialog.java
public void addActionsTab(final String label, final View.OnClickListener listener) {
TabHost.TabSpec tab = tabHost.newTabSpec("file_actions");
tab.setIndicator("Actions");
tab.setContent(new TabContentFactory() {
@Override
public View createTabContent(String tag) {
LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL);
Button remove = (Button) LayoutInflater.from(getContext()).inflate(R.layout.button_danger, null);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.topMargin = (int) ScaleUtil.getDip(getContext(), 10);
remove.setLayoutParams(params);
remove.setText(label);
remove.setOnClickListener(listener);
layout.addView(remove);
return layout;
}
});
tabHost.addTab(tab);
}
项目:RTP-API-Gradle-Maven-Android-File-Selector-Java
文件:MyFileActivity.java
/**
* @return TabSpec array for my files tab host
*/
private TabHost.TabSpec[] getMyFilesCategories(FileEntity[] allEntities){
List<String> myFilesSubCategoriesList = FileSelectHelper.getMyFilesSubCategories(allEntities);
TabHost.TabSpec[] myFilesSubCategories = new TabHost.TabSpec[myFilesSubCategoriesList.size()];
Iterator<String> categoriesIter = myFilesSubCategoriesList.iterator();
for(int i = 0; i < myFilesSubCategories.length; i++) {
String subCategoryName = categoriesIter.next();
myFilesSubCategories[i] = tabHostMyFile.newTabSpec(subCategoryName);
myFilesSubCategories[i].setIndicator(FileSelectHelper.myFilesCategoriesMap.get(subCategoryName));
myFilesSubCategories[i].setContent(R.id.myFileList);
}
return myFilesSubCategories;
}
项目:PowerToggles
文件:FolderPick.java
@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);
}
项目:faims-android
文件:FileGalleryPreviewDialog.java
public void addVideoPreview(View view) {
if (view instanceof VideoView) {
videoView = (VideoView) view;
}
TabHost.TabSpec tab = tabHost.newTabSpec("video_preview");
tab.setIndicator("Video Preview");
tab.setContent(new TabContentFactory() {
@Override
public View createTabContent(String tag) {
LinearLayout layout = new LinearLayout(getContext());
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(videoView, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
return layout;
}
});
tabHost.addTab(tab);
}
项目:easyapi-apm-demo
文件:TabWebViewActivity.java
@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));
}
项目:AutoAnswerCalls
文件:MainActivity.java
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);
}
项目:RTP-API-Gradle-Maven-Android-File-Selector-Java
文件:SampleFileActivity.java
/**
* @return TabSpec array for sample files tab host
*/
private TabHost.TabSpec[] getSampleFilesSubCategories(){
List<String> sampleFilesSubCategoriesList = FileSelectHelper.getSampleFilesSubCategories();
TabHost.TabSpec[] sampleFilesSubCategories = new TabHost.TabSpec[sampleFilesSubCategoriesList.size()];
Iterator<String> categoriesIter = sampleFilesSubCategoriesList.iterator();
for(int i = 0; i < sampleFilesSubCategories.length; i++) {
String subCategoryName = categoriesIter.next();
sampleFilesSubCategories[i] = tabHostSampleFile.newTabSpec(subCategoryName);
sampleFilesSubCategories[i].setIndicator(FileSelectHelper.sampleCategoriesMap.get(subCategoryName));
sampleFilesSubCategories[i].setContent(R.id.sampleFileList);
}
return sampleFilesSubCategories;
}
项目:JARVIS
文件:HelpFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (view == null) {
view = inflater.inflate(R.layout.fragment_help, container, false);
TabHost mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
mTabHost.setup();
ViewPager mViewPager = (ViewPager) view.findViewById(R.id.pager);
TabsAdapter mTabsAdapter = new TabsAdapter(getActivity(), mTabHost, mViewPager);
// Here we load the content for each tab.
mTabsAdapter.addTab(mTabHost.newTabSpec("one").setIndicator("Setup"), PageOneFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("two").setIndicator("Using"), PageTwoFragment.class, null);
mTabsAdapter.addTab(mTabHost.newTabSpec("three").setIndicator("FAQ"), PageThreeFragment.class, null);
}
return view;
}
项目:Doctor
文件:UserProfile.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.medical_records, container, false);
mViewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
mTabHost = (TabHost) rootView.findViewById(android.R.id.tabhost);
mHorizontalScroll = (HorizontalScrollView) rootView.findViewById(R.id.horizontal_scroll_view);
mTabHost.setCurrentTab(1);
avatar = (ImageView) rootView.findViewById(R.id.user_avatar);
userCode = (TextView) rootView.findViewById(R.id.user_code);
fullName = (TextView) rootView.findViewById(R.id.full_name);
birthDate = (TextView) rootView.findViewById(R.id.birth_date);
specialty = (TextView) rootView.findViewById(R.id.specialty2);
return rootView;
}
项目:appFirst
文件:MainActivity.java
private void initTabs() {
MainTabs[] tabs = MainTabs.values();
for (MainTabs tab : tabs) {
TabHost.TabSpec tabSpec = mTabHost.newTabSpec(getString(tab.getNameRes()));
View indicator = inflateView(R.layout.view_tab_main_indicator);
ImageView icon = (ImageView) indicator.findViewById(R.id.tab_icon);
icon.setImageResource(tab.getIconRes());
TextView title = (TextView) indicator.findViewById(R.id.tab_titile);
title.setText(getString(tab.getNameRes()));
tabSpec.setIndicator(indicator);
tabSpec.setContent(new TabHost.TabContentFactory() {
@Override
public View createTabContent(String tag) {
return new View(MainActivity.this);
}
});
mTabHost.addTab(tabSpec, tab.getClazz(), null);
}
}
项目:stynico
文件:ToolsPopWindow.java
private void initTab(){
this.toolsTabView = this.toolsTabInflater.inflate(R.layout.tabactivity_tools,null);
this.toolsTab = (TabHost) this.toolsTabView.findViewById(android.R.id.tabhost); //获取tabhost
this.toolsTab.setup(); //使用findViewById()加载tabhost时在调用addTab前必须调用
this.toolsTab.addTab(this.toolsTab.newTabSpec("normal").setIndicator("常用").setContent(R.id.tools_normal));
this.toolsTab.addTab(this.toolsTab.newTabSpec("setttings").setIndicator("设置").setContent(R.id.tools_settings));
this.toolsTab.addTab(this.toolsTab.newTabSpec("tool").setIndicator("工具").setContent(R.id.tools_tool));
this.toolsTab.setCurrentTab(0); //设置默认选种标签
}
项目:mobile-store
文件:TabsAdapter.java
TabsAdapter(Activity activity, TabHost tabHost, ViewPager pager) {
context = activity;
this.tabHost = tabHost;
viewPager = pager;
this.tabHost.setOnTabChangedListener(this);
viewPager.setAdapter(this);
viewPager.setOnPageChangeListener(this);
}
项目:apps_small
文件:TabsFragment.java
@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;
}
项目:apps_small
文件:TabsFragment.java
/**
* 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;
}
项目:open-rmbt
文件:QoSTestDetailPagerFragment.java
@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;
}
项目:open-rmbt
文件:RMBTResultPagerFragment.java
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;
}
项目:mupdf-android-viewer-nui
文件:DocActivityView.java
protected void setupTabs()
{
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();
// get the tab tags.
mTagHidden = getResources().getString(R.string.hidden_tab);
mTagFile = getResources().getString(R.string.file_tab);
mTagAnnotate = getResources().getString(R.string.annotate_tab);
mTagPages = getResources().getString(R.string.pages_tab);
// first tab is and stays hidden.
// when the search tab is selected, we programmatically "select" this hidden tab
// which results in NO tabs appearing selected in this tab host.
setupTab(tabHost, mTagHidden, R.id.hiddenTab, R.layout.tab);
tabHost.getTabWidget().getChildTabViewAt(0).setVisibility(View.GONE);
// these tabs are shown.
setupTab(tabHost, mTagFile, R.id.fileTab, R.layout.tab_left);
setupTab(tabHost, mTagAnnotate, R.id.annotateTab, R.layout.tab);
setupTab(tabHost, mTagPages, R.id.pagesTab, R.layout.tab_right);
// start by showing the edit tab
tabHost.setCurrentTabByTag(mTagFile);
tabHost.setOnTabChangedListener(this);
}
项目:mupdf-android-viewer-nui
文件:DocActivityView.java
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);
}
项目:gamesboard
文件:ContactDetailFragment.java
@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;
}
项目:Review-
文件:MainActivity.java
private void initView() {
//测试栏目的题目统计TextView
mCount = (TextView) findViewById(R.id.tv_count);
mDoubleClickExit = new DoubleClickExitHelper(this);
Indicator[] indicators = Indicator.values();
mFragmentTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mFragmentTabHost.setup(getApplicationContext(), getSupportFragmentManager(), R.id.realtabcontent);
//初始化Tab
for (int i = 0; i < indicators.length; i++){
TabHost.TabSpec tabSpec = mFragmentTabHost.newTabSpec(getString(indicators[i].getResName()));
tabSpec.setIndicator(getIndicatorView(indicators[i]));
mFragmentTabHost.addTab(tabSpec, indicators[i].getClz(), null);
}
//去除底部按钮之间的分割线
if (android.os.Build.VERSION.SDK_INT > 10) {
mFragmentTabHost.getTabWidget().setShowDividers(0);
mFragmentTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
if(tabId.equals(getString(Indicator.TEST.getResName()))){
mCount.setVisibility(View.VISIBLE);
}else{
mCount.setVisibility(View.GONE);
}
}
});
}}
项目:Android-Fitness
文件:MainActivity.java
private void initTabView() {
// ʵ����tabhost
this.tabHost = (TabHost) findViewById(R.id.mytabhost);
// ���ڼ̳���ActivityGroup��������Ҫ��setup���������˲��������̳�TabActivity���ʡ��
tabHost.setup(this.getLocalActivityManager());
// ������ǩ
for (int i = 0; i < activitys.length; i++) {
// ʵ����һ��view��Ϊtab��ǩ�IJ���
View view = View.inflate(this, R.layout.main_tab_layout, null);
// ����imageview
ImageView imageView = (ImageView) view.findViewById(R.id.image);
imageView.setImageDrawable(getResources().getDrawable(image[i]));
// ����textview
TextView textView = (TextView) view.findViewById(R.id.title);
textView.setText(title[i]);
// ������תactivity
Intent intent = new Intent(this, activitys[i]);
// ����view����������ת��activity
TabSpec spec = tabHost.newTabSpec(title[i]).setIndicator(view).setContent(intent);
// ��ӵ�ѡ�
tabHost.addTab(spec);
}
}