TypedArray.GetSourceResourceId(Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳指定屬性所解析的樣式或版面的資源 ID,否則回傳 defValue。
[Android.Runtime.Register("getSourceResourceId", "(II)I", "GetGetSourceResourceId_IIHandler", ApiSince=29)]
public virtual int GetSourceResourceId(int index, int defaultValue);
[<Android.Runtime.Register("getSourceResourceId", "(II)I", "GetGetSourceResourceId_IIHandler", ApiSince=29)>]
abstract member GetSourceResourceId : int * int -> int
override this.GetSourceResourceId : int * int -> int
參數
- index
- Int32
要檢索來源樣式的屬性索引。
- defaultValue
- Int32
如果該屬性未定義或非資源,則返回的值。
傳回
如果在樣式或版面中未被解析,則是樣式資源 ID、版面資源 ID,或是 defaultValue。
- 屬性
備註
回傳指定屬性所解析的樣式或版面的資源 ID,否則回傳 defValue。
例如,如果你解析兩個屬性android:attribute1和android:attribute2,你從 中膨脹 :android.view.Viewlayout/my_layout.xml
<View
style="@style/viewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:attribute1="foo"/>
且 @style/viewStyle 為:
<style android:name="viewStyle">
<item name="android:attribute2">bar<item/>
<style/>
則解析 TypedArray 將有 回傳來源資源 ID 的 R.layout.my_layout 值,對於 android:attribute1R.style.viewStyleandroid:attribute2和 。
Java 文件 android.content.res.TypedArray.getSourceResourceId(int, int)。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。