原链接:http://developer.android.com/reference/android/widget/TabHost.html

public class

TabHost

extends FrameLayout
implements ViewTreeObserver.OnTouchModeChangeListener
java.lang.Object
android.view.View

android.view.ViewGroup


android.widget.FrameLayout



android.widget.TabHost
Known Direct Subclasses FragmentTabHost

Class Overview

Container for a tabbed window view. This object holds two children: a set of tab labels that the user clicks to select a specific tab, and a FrameLayout object that displays the contents of that page. The individual elements are typically controlled using this container object, rather than setting values on the child elements themselves.

Summary

Nested Classes
interface TabHost.OnTabChangeListener Interface definition for a callback to be invoked when tab changed








interface TabHost.TabContentFactory Makes the content of a tab when it is selected.








class TabHost.TabSpec A tab has a tab indicator, content, and a tag that is used to keep track of it.








[Expand] Inherited XML Attributes










From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
[Expand] Inherited Constants










From class android.view.ViewGroup
From class android.view.View
[Expand] Inherited Fields










From class android.view.View
Public Constructors

TabHost( Context context)










TabHost( Context context, AttributeSet attrs)









Public Methods
void addTab( TabHost.TabSpec tabSpec) Add a tab.









void clearAllTabs() Removes all tabs from the tab widget associated with this tab host.









boolean dispatchKeyEvent( KeyEvent event) Dispatch a key event to the next view on the focus path.









void dispatchWindowFocusChanged(boolean hasFocus) Called when the window containing this view gains or loses window focus.









int getCurrentTab()









String getCurrentTabTag()









View getCurrentTabView()









View getCurrentView()









FrameLayout getTabContentView() Get the FrameLayout which holds tab content









TabWidget getTabWidget()









TabHost.TabSpec newTabSpec( String tag) Get a new TabHost.TabSpec associated with this tab host.









void onInitializeAccessibilityEvent( AccessibilityEvent event) Initializes an AccessibilityEvent with information about this View which is the event source.









void onInitializeAccessibilityNodeInfo( AccessibilityNodeInfo info) Initializes an AccessibilityNodeInfo with information about this view.









void onTouchModeChanged(boolean isInTouchMode) Callback method to be invoked when the touch mode changes.









void sendAccessibilityEvent(int eventType) Sends an accessibility event of the given type.









void setCurrentTab(int index)









void setCurrentTabByTag( String tag)









void setOnTabChangedListener( TabHost.OnTabChangeListener l) Register a callback to be invoked when the selected state of any of the items in this list changes









void setup()

Call setup() before adding tabs if loading TabHost using findViewById().











void setup( LocalActivityManager activityGroup) If you are using setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity.









Protected Methods
void onAttachedToWindow() This is called when the view is attached to a window.









void onDetachedFromWindow() This is called when the view is detached from a window.









[Expand] Inherited Methods










From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.ViewTreeObserver.OnTouchModeChangeListener
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public TabHost(Context context)

Added in API level 1


public TabHost(Context context, AttributeSet attrs)

Added in API level 1


Public Methods

public void addTab(TabHost.TabSpec tabSpec)

Added in API level 1

Add a tab.

Parameters
tabSpec Specifies how to create the indicator and content.

public void clearAllTabs()

Added in API level 1

Removes all tabs from the tab widget associated with this tab host.

public boolean dispatchKeyEvent(KeyEvent event)

Added in API level 1

Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.

Parameters
event The key event to be dispatched.
Returns
  • True if the event was handled, false otherwise.

public void dispatchWindowFocusChanged(boolean hasFocus)

Added in API level 1

Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.

Parameters
hasFocus True if the window containing this view now has focus, false otherwise.

public int getCurrentTab()

Added in API level 1


public StringgetCurrentTabTag()

Added in API level 1


public ViewgetCurrentTabView()

Added in API level 1


public ViewgetCurrentView()

Added in API level 1


public FrameLayoutgetTabContentView()

Added in API level 1

Get the FrameLayout which holds tab content

public TabWidgetgetTabWidget()

Added in API level 1


public TabHost.TabSpecnewTabSpec(String tag)

Added in API level 1

Get a new TabHost.TabSpec associated with this tab host.

Parameters
tag required tag of tab.

public void onInitializeAccessibilityEvent(AccessibilityEvent event)

Added in API level 14

Initializes an AccessibilityEvent with information about this View which is the event source. In other words, the source of an accessibility event is the view whose state change triggered firing the event.

Example: Setting the password property of an event in addition to properties set by the super implementation:

publicvoid onInitializeAccessibilityEvent(AccessibilityEventevent){
super.onInitializeAccessibilityEvent(event);
event.setPassword(true);
}

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) itsonInitializeAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.


Parameters
event The event to initialize.

public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)

Added in API level 14

Initializes an AccessibilityNodeInfo with information about this view. The base implementation sets:

  • setParent(View),

  • setBoundsInParent(Rect),

  • setBoundsInScreen(Rect),

  • setPackageName(CharSequence),

  • setClassName(CharSequence),

  • setContentDescription(CharSequence),

  • setEnabled(boolean),

  • setClickable(boolean),

  • setFocusable(boolean),

  • setFocused(boolean),

  • setLongClickable(boolean),

  • setSelected(boolean),

Subclasses should override this method, call the super implementation, and set additional attributes.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) itsonInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) is responsible for handling this call.


Parameters
info The instance to initialize.

public void onTouchModeChanged(boolean isInTouchMode)

Added in API level 1

Callback method to be invoked when the touch mode changes.

Parameters
isInTouchMode True if the view hierarchy is now in touch mode, false otherwise.

public void sendAccessibilityEvent(int eventType)

Added in API level 4

Sends an accessibility event of the given type. If accessibility is not enabled this method has no effect. The default implementation callsonInitializeAccessibilityEvent(AccessibilityEvent) first to populate information about the event source (this View), then callsdispatchPopulateAccessibilityEvent(AccessibilityEvent) to populate the text content of the event source including its descendants, and last callsrequestSendAccessibilityEvent(View, AccessibilityEvent) on its parent to resuest sending of the event to interested parties.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) itssendAccessibilityEvent(View, int) is responsible for handling this call.


Parameters
eventType The type of the event to send, as defined by several types from AccessibilityEvent, such as TYPE_VIEW_CLICKED orTYPE_VIEW_HOVER_ENTER.

public void setCurrentTab(int index)

Added in API level 1


public void setCurrentTabByTag(String tag)

Added in API level 1


public void setOnTabChangedListener(TabHost.OnTabChangeListener l)

Added in API level 1

Register a callback to be invoked when the selected state of any of the items in this list changes

Parameters
l The callback that will run

public void setup()

Added in API level 1


Call setup() before adding tabs if loading TabHost using findViewById(). However: You do not need to call setup() after getTabHost() in TabActivity. Example:

mTabHost =(TabHost)findViewById(R.id.tabhost);
mTabHost
.setup();
mTabHost
.addTab(TAB_TAG_1,"Hello, world!","Tab 1");


public void setup(LocalActivityManager activityGroup)

Added in API level 1

If you are using setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity. This is done for you if you extend TabActivity.

Parameters
activityGroup Used to launch activities for tab content.

Protected Methods

protected void onAttachedToWindow()

Added in API level 1

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

protected void onDetachedFromWindow()

Added in API level 1

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.


更多相关文章

  1. Android Firebase Dynamic Links 动态链接使用心得
  2. Android 网络链接,不要忘记添加网络权限。
  3. Android指定调用系统自带浏览器打开链接
  4. Android中TextView中加图片,超链接,部分字或者背景变色。。。
  5. Android 单元测试链接整理
  6. Android中TextView中加图片,超链接,部分字或者背景变色。。。不断
  7. C#实现添加Word文本与图片超链接的方法
  8. XML关于图像超链接的制作的代码实例
  9. XML-在xslt中添加链接的方式的代码分享

随机推荐

  1. 将jQuery集转换为HTML
  2. JQuery-Dialog(弹出窗口,遮蔽窗口)
  3. 非常好用的JQuery自动补全插件bigautocom
  4. 查询下拉框只显示年份(jquery年份插件)
  5. jQuery serialize()在IE中不使用ajax加载
  6. 解析jquery实现回车键提交表单
  7. jquery中的Datepicker控件如何默认显示日
  8. 在某个点停止固定位置滚动?
  9. 使用jquery tablesorter插件,有一个选中项
  10. js是否为空判断大全