| TabHost() | ใช้สร้าง Object TabHost |
|---|---|
| addTab() | ใช้เพิ่ม Object TabSpec เข้าไปใน Object TabHost |
| clearAllTabs() | ใช้ลบ tab ทั้งหมดออกจาก Object TabHost |
| getCurrentTab() | ใช้คืนค่า ตำแหน่งของ Tab ปัจจุบัน ที่กำลัง Focus อยู่ |
| getCurrentTabTag() | ใช้คืนค่า tag ของ Tab ปัจจุบัน ที่กำลัง Focus อยู่ |
| getCurrentTabView() | ใช้คืนค่า Object View ที่เป็น tab ปัจจุบันที่กำลัง Focus อยู่ |
| getTabContentView() | ใช้คืนค่า content view ของ tab ปัจจุบันที่กำลัง Focus อยู่ |
| getTabWidget() | ใช้คืนค่า Object TabWidget ของ Object TabHost |
| newTabSpec() | ใช้สร้าง Object TabHost.TabSpec |
| setCurrentTab() | ใช้กำหนด ตำแหน่ง ของ tab ปัจจุบัน ที่ต้องการให้ได้รับ Focus อยู่ |
| setCurrentTabByTag() | ใช้กำหนด tab ปัจจุบัน ที่ต้องการให้ได้รับ Focus อยู่ โดยการกำหนดจาก tag ของ tab |
| setup() | จะต้องเรียกใช้คำสั่งนี้ ก่อนที่จะ เพิ่ม tabSpec เข้าไปใน Object TabHost เสมอ |
| onTouchModeChanged() | เป็น method ที่ใช้สำหรับการ overridde โดย method นี้จะถูกเรียกใช้เมื่อ มีการเปลี่ยนแปลง touch mode |
| setOnTabChangedListener() | ใช้กำหนด การดักฟังเหตุการณ์ เมื่อมีการ เปลี่ยน focus ของ tab ใน Object TabHost |
| onAttachedToWindow() | เป็น method ที่ใช้สำหรับการ overridde โดย method นี้จะถูกเรียกใช้เมื่อ TabHost เริ่มถูกแสดงใน window |
| onDetachedFromWindow() | เป็น method ที่ใช้สำหรับการ overridde โดย method นี้จะถูกเรียกใช้เมื่อ TabHost ออกจากการแสดงผลใน window |
method:TabHost ( Context context )
return type:TabHost
content:ใช้สร้าง Object TabHost
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec.setContent ( button.getId ( ) ); tab_spec.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec ); setContentView ( tab_host ); } }
method:addTab ( TabHost.TabSpec tabSpec )
return type:void
content:ใช้เพิ่ม Object TabSpec เข้าไปใน Object TabHost
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec.setContent ( button.getId ( ) ); tab_spec.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec ); setContentView ( tab_host ); } }
method:clearAllTabs ( )
return type:void
content:ใช้ลบ tab ทั้งหมดออกจาก Object TabHost
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec.setContent ( button.getId ( ) ); tab_spec.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec ); tab_host.clearAllTabs ( ); setContentView ( tab_host ); } }
method:getCurrentTab ( )
return type:int
content:ใช้คืนค่า ตำแหน่งของ Tab ปัจจุบัน ที่กำลัง Focus อยู่
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); int current_tab = tab_host.getCurrentTab ( ); setContentView ( tab_host ); } }
method:getCurrentTabTag ( )
return type:string
content:ใช้คืนค่า tag ของ Tab ปัจจุบัน ที่กำลัง Focus อยู่
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); String tag_tab = tab_host.getCurrentTabTag ( ); setContentView ( tab_host ); } }
method:getCurrentTabView ( )
return type:View
content:ใช้คืนค่า Object View ที่เป็น tab ปัจจุบันที่กำลัง Focus อยู่
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); View view_tab = tab_host.getCurrentTabView ( ); setContentView ( tab_host ); } }
method:getTabContentView ( )
return type:FrameLayout
content:ใช้คืนค่า content view ของ tab ปัจจุบันที่กำลัง Focus อยู่
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); FrameLayout frame_layout = tab_host.getTabContentView ( ); setContentView ( tab_host ); } }
method:getTabWidget ( )
return type:TabWidget
content:ใช้คืนค่า Object TabWidget ของ Object TabHost
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); TabWidget tab_widget = tab_host.getTabWidget ( ); setContentView ( tab_host ); } }
method:newTabSpec ( String tag )
return type:TabHost.TabSpec
content:ใช้สร้าง Object TabHost.TabSpec
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); TabWidget tab_widget = tab_host.getTabWidget ( ); setContentView ( tab_host ); } }
method:setCurrentTab ( int index )
return type:void
content:ใช้กำหนด ตำแหน่ง ของ tab ปัจจุบัน ที่ต้องการให้ได้รับ Focus อยู่
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); tab_host.setCurrentTab ( 1 ); setContentView ( tab_host ); } }
method:setCurrentTabByTag ( String tag )
return type:void
content:ใช้กำหนด tab ปัจจุบัน ที่ต้องการให้ได้รับ Focus อยู่ โดยการกำหนดจาก tag ของ tab
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); tab_host.setCurrentTabByTag ( "tag_two" ); setContentView ( tab_host ); } }
method:setup ( )
return type:void
content:จะต้องเรียกใช้คำสั่งนี้ ก่อนที่จะ เพิ่ม tabSpec เข้าไปใน Object TabHost เสมอ
example:public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); setContentView ( tab_host ); } }
method:onTouchModeChanged ( boolean isInTouchMode )
return type:void
content:เป็น method ที่ใช้สำหรับการ overridde โดย method นี้จะถูกเรียกใช้เมื่อ มีการเปลี่ยนแปลง touch mode
example:public class BambooView extends TabHost { public void onTouchModeChanged ( boolean isInTouchMode ) { } }
method:setOnTabChangedListener ( TabHost.OnTabChangeListener l )
return type:void
content:ใช้กำหนด การดักฟังเหตุการณ์ เมื่อมีการ เปลี่ยน focus ของ tab ใน Object TabHost
example:public class AndroidBamboo extends Activity implements TabHost.OnTabChangeListener { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); TabHost tab_host = new TabHost ( this ); tab_host.setup(); TabHost.TabSpec tab_spec_1 = tab_host.newTabSpec ( "tag_one" ); Button button = new Button ( this ); tab_spec_1.setContent ( button.getId ( ) ); tab_spec_1.setIndicator( "TestButton" ); tab_host.addTab ( tab_spec_1 ); TabHost.TabSpec tab_spec_2 = tab_host.newTabSpec ( "tag_two" ); TextView text_view = new TextView ( this ); tab_spec_2.setContent ( text_view.getId ( ) ); tab_spec_2.setIndicator( "TestTextView" ); tab_host.addTab ( tab_spec_2 ); tab_host.setOnTabChangedListener( this ); setContentView ( tab_host ); } public void onTabChanged ( String tabId ) { } }
method:onAttachedToWindow ( )
return type:void
content:เป็น method ที่ใช้สำหรับการ overridde โดย method นี้จะถูกเรียกใช้เมื่อ TabHost เริ่มถูกแสดงใน window
example:public class BambooView extends TabHost { protected void onAttachedToWindow ( ) { } }
method:onDetachedFromWindow ( )
return type:void
content:เป็น method ที่ใช้สำหรับการ overridde โดย method นี้จะถูกเรียกใช้เมื่อ TabHost ออกจากการแสดงผลใน window
example:public class BambooView extends TabHost { protected void onDetachedFromWindow ( ) { } }