Reference
Reference ในเว็บไซต์ Function.in.th เป็นการนำเสนอความรู้ในรูปแบบของแหล่งอ้างอิงของคำสั่งต่าง ๆ ที่ใช้ในการเขียนโปรแกรม โดยผู้ที่สนใจสามารถเข้ามาเรียนรู้การใช้งานคำสั่งของการเขียนโปรแกรมเหล่านี้ได้ ผ่านทาง URL code.function.in.th ทั้งนี้ผู้อ่านยังสามารถร่วมแสดงความคิดเห็นบนเนื้อหาที่มีสอนได้ ซึ่งถือเป็นการส่งเสริมให้มีการแลกเปลี่ยนประสบการณ์และความรู้ระหว่างผู้อ่านด้วยกันเอง
-
Toast() ใช้สร้าง Object Toast cancel() ใช้ปิด toast getDuration() ใช้คืนค่าระยะเวลาที่ toast ถูกแสดง getGravity() ใช้คืนค่า gravity ของ toast getHorizontalMargin() ใช้คืนค่า margin horizontal ของ toast getVerticalMargin() ใช้คืนค่า margin vertical ของ toast getView() ใช้คืนค่า Object View ที่ถูกกำหนดให้แสดงบน toast getXOffset() ใช้คืนค่า ตำแหน่งแกน x ของ toast getYOffset() ใช้คืนค่า ตำแหน่งแกน y ของ toast makeText ( context, resId, duration ) ใช้สร้าง Object Toast makeText ( context, text, duration ) ใช้สร้าง Object Toast setDuration() ใช้กำหนดระยะเวลาที่จะให้ toast ถูกแสดง setGravity() ใช้กำหนด ตำแหน่งที่จะให้ toast แสดง setMargin() ใช้กำหนด margin ให้กับ toast ทั้งแนวตั้งและแนวนอน setText ( resId ) ใช้กำหนดข้อความที่จะแสดงบน toast setText ( text ) ใช้กำหนดข้อความที่จะแสดงบน toast setView() ใช้กำหนด Object View ที่จะให้แสดงบน toast show() ใช้กำหนดให้แสดง toast -
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- Toast()
method :Toast ( Context context )
return type :Toast
content :ใช้สร้าง Object Toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- cancel()
method :cancel ( )
return type :void
content :ใช้ปิด toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); toast.cancel ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- getDuration()
method :getDuration ( )
return type :int
content :ใช้คืนค่าระยะเวลาที่ toast ถูกแสดง
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); int duration = toast.getDuration ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- getGravity()
method :getGravity ( )
return type :int
content :ใช้คืนค่า gravity ของ toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); int gravity = toast.getGravity ( ); } }
-
method :
getHorizontalMargin ( )
return type :float
content :ใช้คืนค่า margin horizontal ของ toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); float margin_horizontal = toast.getHorizontalMargin ( ); } }
-
method :
getVerticalMargin ( )
return type :float
content :ใช้คืนค่า margin vertical ของ toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); float margin_vertical = toast.getVerticalMargin ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- getView()
method :getView ( )
return type :View
content :ใช้คืนค่า Object View ที่ถูกกำหนดให้แสดงบน toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); TextView text = new TextView ( this ); text.setText ( "Welcome To BambooLabCode.Com" ); toast.setView ( text ); View view = toast.getView ( ); toast.show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- getXOffset()
method :getXOffset ( )
return type :int
content :ใช้คืนค่า ตำแหน่งแกน x ของ toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); int toast_x = toast.getXOffset ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- getYOffset()
method :getYOffset ( )
return type :int
content :ใช้คืนค่า ตำแหน่งแกน y ของ toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = new Toast ( this ); toast.makeText ( this, "Welcome To BambooLabCode.com", Toast.LENGTH_LONG ).show ( ); int toast_y = toast.getYOffset ( ); } }
-
method :
makeText ( Context context, int resId, int duration )
return type :Toast
content :ใช้สร้าง Object Toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast.makeText ( this, R.string.welcome, Toast.LENGTH_LONG ).show ( ); } }
-
method :
makeText ( Context context, CharSequence text, int duration )
return type :Toast
content :ใช้สร้าง Object Toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ).show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- setDuration()
method :setDuration ( int duration )
return type :void
content :ใช้กำหนดระยะเวลาที่จะให้ toast ถูกแสดง
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); toast.setDuration ( Toast.LENGTH_SHORT ); toast.show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- setGravity()
method :setGravity ( int gravity, int xOffset, int yOffset )
return type :void
content :ใช้กำหนด ตำแหน่งที่จะให้ toast แสดง
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); toast.setGravity ( Gravity.RIGHT, 100, 100 ); toast.show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- setMargin()
method :setMargin ( float horizontalMargin, float verticalMargin )
return type :void
content :ใช้กำหนด margin ให้กับ toast ทั้งแนวตั้งและแนวนอน
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); toast.setMargin ( 150, 100 ); toast.show ( ); } }
-
method :
setText ( int resId )
return type :void
content :ใช้กำหนดข้อความที่จะแสดงบน toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); toast.setText ( R.string.welcome ); toast.show ( ); } }
-
method :
setText ( CharSequence s )
return type :void
content :ใช้กำหนดข้อความที่จะแสดงบน toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); toast.setText ( "Welcome To Function.in.th" ); toast.show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- setView()
method :setView ( View view )
return type :void
content :ใช้กำหนด Object View ที่จะให้แสดงบน toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); Button button = new Button ( this ); button.setText ( "Welcome To BambooLabCode.Com" ); toast.setView ( button ); toast.show ( ); } }
-
- Reference
- ::
- Android-Widget
- ::
- Class Toast
- ::
- show()
method :show ( )
return type :void
content :ใช้กำหนดให้แสดง toast
example :public class AndroidBamboo extends Activity { public void onCreate( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ); Toast toast = Toast.makeText ( this, "Welcome To BambooLabCode.Com", Toast.LENGTH_LONG ); TextView text = new TextView ( this ); text.setText ( "Welcome To BambooLabCode.Com" ); toast.setView ( text ); toast.show ( ); } }