語言

Activity.RequireViewById 方法

定義

多載

名稱 Description
RequireViewById(Int32)

尋找由 XML 屬性識別 android:id 的視圖,該屬性在 中處理 #onCreate,或若 ID 無效或階層中無匹配視圖,則拋出 IllegalArgumentException。

RequireViewById<T>(Int32)

RequireViewById(Int32)

尋找由 XML 屬性識別 android:id 的視圖,該屬性在 中處理 #onCreate,或若 ID 無效或階層中無匹配視圖,則拋出 IllegalArgumentException。

[Android.Runtime.Register("requireViewById", "(I)Landroid/view/View;", "", ApiSince=28)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T extends android.view.View" })]
public Java.Lang.Object RequireViewById(int id);
[<Android.Runtime.Register("requireViewById", "(I)Landroid/view/View;", "", ApiSince=28)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T extends android.view.View" })>]
member this.RequireViewById : int -> Java.Lang.Object

參數

id
Int32

搜尋的 ID

傳回

具有指定 ID 的視圖

屬性

備註

尋找由 android:id XML 屬性識別且在 onCreate(Bundle) 中處理過的視圖,若 ID 無效或階層中無匹配視圖,則拋出 IllegalArgumentException。 注意:在大多數情況下——視編譯器支援而定——產生的視圖會自動投射成目標類別類型。 若目標類別類型不受限制,則可能需要明確施放。

另請參閱:

Android 參考資料。android.app.Activity.requireViewById

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

適用於

RequireViewById<T>(Int32)

public T RequireViewById<T>(int id) where T : Android.Views.View;
member this.RequireViewById : int -> 'T (requires 'T :> Android.Views.View)

類型參數

T

參數

id
Int32

傳回

T

備註

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

適用於