語言

Button 建構函式

定義

多載

名稱 Description
Button(Context)

用程式碼創建按鈕時使用的簡單構造器。

Button(Context, IAttributeSet)

LayoutInflater 當從 XML 膨脹按鈕時,會呼叫這個建構子。

Button(IntPtr, JniHandleOwnership)

用於建立 JNI 物件受管理表示的建構器;由執行時呼叫。

Button(Context, IAttributeSet, Int32)

這個建構子允許按鈕子類別在膨脹時使用其專屬的主題屬性基礎風格。

Button(Context, IAttributeSet, Int32, Int32)

這個建構器允許按鈕子類別在膨脹時使用其專屬的主題屬性或風格資源的職業專用基礎風格。

Button(Context)

用程式碼創建按鈕時使用的簡單構造器。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")]
public Button(Android.Content.Context? context);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "")>]
new Android.Widget.Button : Android.Content.Context -> Android.Widget.Button

參數

context
Context

按鈕運行的上下文,透過它可以存取當前主題、資源等。

屬性

備註

用程式碼創建按鈕時使用的簡單構造器。

Java 文件 android.widget.Button.Button(android.content.Context)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

Button(Context, IAttributeSet)

LayoutInflater 當從 XML 膨脹按鈕時,會呼叫這個建構子。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "")]
public Button(Android.Content.Context? context, Android.Util.IAttributeSet? attrs);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;)V", "")>]
new Android.Widget.Button : Android.Content.Context * Android.Util.IAttributeSet -> Android.Widget.Button

參數

context
Context

視圖運行的上下文,透過它能存取當前主題、資源等。

attrs
IAttributeSet

XML 按鈕標籤的屬性被用來膨脹視圖。

屬性

備註

LayoutInflater 當從 XML 膨脹按鈕時,會呼叫這個建構子。 由當前主題 android.R.attr#buttonStyle android:buttonStyle 的覆蓋基礎視圖屬性所定義的屬性。

通常你不會呼叫這個建構子來建立你自己的按鈕實例。 不過,在 建立自訂視圖時,你必須覆寫這個建構器。

Java 文件 android.widget.Button.Button(android.content.Context, android.util.AttributeSet)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

Button(IntPtr, JniHandleOwnership)

用於建立 JNI 物件受管理表示的建構器;由執行時呼叫。

protected Button(IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.Widget.Button : nativeint * Android.Runtime.JniHandleOwnership -> Android.Widget.Button

參數

javaReference
IntPtr

nativeint

IntPtrA 包含一個 Java 原生介面(JNI)物件參考。

transfer
JniHandleOwnership

JniHandleOwnershipA 指示如何處理javaReference

備註

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

Button(Context, IAttributeSet, Int32)

這個建構子允許按鈕子類別在膨脹時使用其專屬的主題屬性基礎風格。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")]
public Button(Android.Content.Context? context, Android.Util.IAttributeSet? attrs, int defStyleAttr);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "")>]
new Android.Widget.Button : Android.Content.Context * Android.Util.IAttributeSet * int -> Android.Widget.Button

參數

context
Context

按鈕運行的上下文,透過它可以存取當前主題、資源等。

attrs
IAttributeSet

就是膨脹視圖的 XML 按鈕標籤的屬性。

defStyleAttr
Int32

目前主題中屬性的資源識別碼,其值為樣式的資源 ID。 指定樣式的屬性值作為按鈕的預設值。 將此參數設為 0,以避免使用預設值。

屬性

備註

這個建構子允許按鈕子類別在膨脹時使用其專屬的主題屬性基礎風格。 由當前主題 defStyleAttr 的覆蓋基礎視圖屬性所定義的屬性。

關於 Button 的基礎視圖屬性,請參見 android.R.styleable#Button Button Attributes、 android.R.styleable#TextView TextView Attributesandroid.R.styleable#View View Attributes、 。

Java 文件 android.widget.Button.Button(android.content.Context, android.util.AttributeSet, int)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於

Button(Context, IAttributeSet, Int32, Int32)

這個建構器允許按鈕子類別在膨脹時使用其專屬的主題屬性或風格資源的職業專用基礎風格。

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "")]
public Button(Android.Content.Context? context, Android.Util.IAttributeSet? attrs, int defStyleAttr, int defStyleRes);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;Landroid/util/AttributeSet;II)V", "")>]
new Android.Widget.Button : Android.Content.Context * Android.Util.IAttributeSet * int * int -> Android.Widget.Button

參數

context
Context

按鈕運行的上下文,透過它可以存取當前主題、資源等。

attrs
IAttributeSet

就是膨脹視圖的 XML 按鈕標籤的屬性。

defStyleAttr
Int32

目前主題中屬性的資源識別碼,其值為樣式的資源 ID。 指定樣式的屬性值作為按鈕的預設值。 將此參數設為 0,以避免使用預設值。

defStyleRes
Int32

提供按鈕預設值的樣式資源識別碼,僅在 defStyleAttr 為 0 或主題中找不到時使用。 將此參數設為 0,以避免使用預設值。

屬性

備註

這個建構器允許按鈕子類別在膨脹時使用其專屬的主題屬性或風格資源的職業專用基礎風格。 若想了解根據你對此建構子的輸入如何解析特定屬性的最終值,請參見 android.view.View#View(Context, AttributeSet, int, int)。

Java 文件 android.widget.Button.Button(android.content.Context, android.util.AttributeSet, int, int)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於